Breaking up a String array

Hi guys!
I have been working on this for a while! I have an assignment which requires:
-take input of a seven digit integer
- break this number apart and perform calculations in order to "encrypt" the number.
-etc..
I thought I should break the string up first, then convert each element to an int for calculations.
I am sure there is a better way to do this.
Could I use a String Tokenizer? How would I do that?
Thanks!!
Here's what I have so far:
import javax.swing.*;
public class Assignment3 {
  public static void main( String args[] ) {
    String choiceString = "",
    output = "",
    stringArray[] = new String[7];
    int intArray[] = new int[7],
    choiceInt;
    while ( choiceString != null ) {
      // prompt user to input a seven digit integer
      choiceString=JOptionPane.showInputDialog("Please     enter the number corresponding to your choice:\n1.Encryption\n2.Decryption\n3.Exit");
      choiceInt = Integer.parseInt( choiceString );
     if( choiceInt != 1 || choiceInt != 2 || choiceInt != 3)
        JOptionPane.showMessageDialog( null, "Invalid selection", "Error",
        JOptionPane.ERROR_MESSAGE );
      // 1=encrypt 2=decrypt 3=exit
      switch ( choiceInt ) {
        case 1:
         stringArray = JOptionPane.showInputDialog( "Please enter a seven digit number:" ) ;
          intArray = convert( stringArray );    // converts string to int
          digitSwap1( intArray );   
          nineModTen( intArray );
          digitSwap2( intArray );
          output += "Original: " + input + "\nOutput: " +  intArray;
          break;
        case 2:
          stringArray = JOptionPane.showInputDialog( "Please enter an encrypted number: " );
          intArray = convert( stringArray );
          digitSwap2( intArray );
          decrypt( intArray );
          digitSwap1( intArray );
          output += "Decrypted: " + input + "\nOutput: " + intArray;
          break;
        case 3:
          output += "Thank you, have a nice day";
          break;
        default:
          JOptionPane.showMessageDialog( null, "Please make a selection", "Error",
          JOptionPane.ERROR_MESSAGE );
          break;
      } // end switch
      JOptionPane.showMessageDialog( null, output, "Results",
      JOptionPane.INFORMATION_MESSAGE );
    } // end loop
    System.exit(0);
  } // end main
  public static void digitSwap1( int array[] )
    int digit1,digit2,digit3,digit4,digit5,digit6,digit7;
    digit1 = array[0];
    digit2 = array[1];
    digit4 = array[3];
    digit5 = array[4];
    digit6 = array[5];
    digit7 = array[6];
    array[0] = digit7;
    array[1] = digit6;
    array[2] = digit5;
    array[4] = digit3;
    array[5] = digit2;
    array[6] = digit1;
    } // end digitSwap1
  public static void nineModTen( int array[] )
    int x = 0;
    while ( x <= 6 ) {
      array[x] = ( array[x] + 9 ) % 10;
      x++;
    } // end loop
  }  // end nineModTen
  public static void digitSwap2( int array[] )
    int digit1,digit2,digit3,digit4,digit5,digit6,digit7;
    digit1 = array[0];
    digit2 = array[1];
    digit3 = array[2];
    digit4 = array[3];
    digit5 = array[4];
    digit6 = array[5];
    array[0] = digit2;
    array[1] = digit1;
    array[2] = digit4;
    array[3] = digit3;
    array[4] = digit6;
    array[5] = digit5;
  }  // end digitSwap2
  public static void decrypt( int array[] )
    int x = 0;
    while ( x <= 6 ) {
      if ( array[x] < 9 )
        array[x] += 1;
      else
        array[x] = 0;
      x++;
    }  // end loop
  } // end decrypt
  public static int[] convert( String array1[] )
    int array2[] = new int[7];   
    int count = 0;
    while ( count <= 6 ) {
      array2[count] = Integer.parseInt( array1[count] );
      count ++;
    } // end loop
    return( array2 );
    } // end convert
} // end class

I have solved my problem! The real problem was that I
was trying to output my resulting int array like this:
output = "result: " + intArraybut I discovered that when I concatenated each individual
element in the array, it worked fine:
output = "result: " + array[0] + array[1] ....Also, I found an easy way to break up the input. Rather
than use the charAt() method to extract each digit, and
then convert for calculation, I converted the String to int
and then, in a loop, extracted each digit from last to
first by: (array[count] = number% 10), then (number = number / 10).
Thanks everyone for your help! I hope this will help
someone else too. Below is the working code.
; > -HB
// this program takes a 7 digit input and "encrypts" it
// by 1st, swapping some of the digits, 2nd, add nine
// and mod ten to each digit, 3rd, swapping digits again.
import javax.swing.*;
public class Assignment3 {
  public static void main( String args[] ) {
    String choiceString = "",
    output = "",
    input;
    int number;
    int intArray[] = new int[7],
    choiceInt = 0;
    while ( choiceString != null ) {
      // prompt user to choose an option
      choiceString=JOptionPane.showInputDialog("Please enter the number corresponding to your choice:\n1.Encryption\n2.Decryption\n3.Exit");
      choiceInt = Integer.parseInt( choiceString );
      // 1=encrypt 2=decrypt 3=exit
      switch ( choiceInt ) {
          case 1:
          input = JOptionPane.showInputDialog( "Please enter a seven digit number:" );
          number = Integer.parseInt( input );
          intArray = convert( number );    // extract each digit
          intArray = digitSwap1( intArray );   
          nineModTen( intArray );
          intArray = digitSwap2( intArray );
          output = "Original: " + input + "\nOutput: " + intArray[0] +
                   intArray[1] + intArray[2] + intArray[3] +
                   intArray[4] + intArray[5] + intArray[6];
          JOptionPane.showMessageDialog( null, output, "Results",
          JOptionPane.INFORMATION_MESSAGE );
          break;
        case 2:
          input = JOptionPane.showInputDialog( "Please enter an encrypted number: " );
          number = Integer.parseInt( input );
          intArray = convert( number );
          intArray = digitSwap2( intArray );
          decrypt( intArray );
          intArray = digitSwap1( intArray );
          output = "Decrypted: " + input + "\nOutput: " + intArray[0] +
                   intArray[1] + intArray[2] + intArray[3] + intArray[4] +
                   intArray[5] + intArray[6];
          JOptionPane.showMessageDialog( null, output, "Results",
          JOptionPane.INFORMATION_MESSAGE );
          break;
        case 3:
          break;
        default:
          JOptionPane.showMessageDialog( null, "Please make a valid selection", "ERROR", JOptionPane.ERROR_MESSAGE);
          break;
      } // end switch
      if ( choiceInt == 3 )
        break;
      } // end loop
      JOptionPane.showMessageDialog( null, "Thank you, Have a nice day!", "EXIT",
      JOptionPane.PLAIN_MESSAGE );
    System.exit(0);
  } // end main
    public static int[] convert( int num )
      int array[] = new int[7];
      int count = 6;
      while ( count >= 0 ) {
        array[ count ] = num % 10;
        num = num / 10;
        count --;
      return array;
  } // end convert
  public static int[] digitSwap1( int array[] )
    int digit1,digit2,digit3,digit5,digit6,digit7;
    digit1 = array[0];
    digit2 = array[1];
    digit3 = array[2];
    digit5 = array[4];
    digit6 = array[5];
    digit7 = array[6];
    array[0] = digit7;
    array[1] = digit6;
    array[2] = digit5;
    array[4] = digit3;
    array[5] = digit2;
    array[6] = digit1;
    return array;   
  } // end digitSwap1
  public static void nineModTen( int array[] )
    int count = 0;
    while ( count < 7 ) {
      array[count] = ( array[count] + 9 ) % 10;
      count++;
    } // end loop
  }  // end nineModTen
  public static int[] digitSwap2( int array[] )
  int digit1,digit2,digit3,digit4,digit5,digit6;
    digit1 = array[0];
    digit2 = array[1];
    digit3 = array[2];
    digit4 = array[3];
    digit5 = array[4];
    digit6 = array[5];
    array[0] = digit2;
    array[1] = digit1;
    array[2] = digit4;
    array[3] = digit3;
    array[4] = digit6;
    array[5] = digit5;
    return array;
  }  // end digitSwap2
  public static void decrypt( int array[] )
    int count = 0;
    while ( count <= 6 ) {
      if ( array[count] < 9 )
        array[count] += 1;
      else
        array[count] = 0;
      count++;
    }  // end loop
   } // end decrypt
  } // end class

Similar Messages

  • How to break up a String into multiple array Strings?

    How do I break up a string into a bunch of String arrays after the line ends.
    For example,
    JTextArea area = new JTextArea();
    this is a string that i have entered in the area declared above
    now here is another sting that is in the same string/text area
    this is all being placed in one text field
    Sting input = area.getText();
    now how do I break that up into an array of strings after each line ends?

    Ok I tested it out and it works.
    So for future refrence to those that come by the same problem I had:
    To split up a string when using a textfield or textarea so that you can store seperate sections of the string based on sperate lines, using the following code:
    String text = area.getText() ;
    String[] lines = text.split("\n") ;
    This will store the following
    this is all one
    entered string
    into two arrays
    Cheers{
    Edited by: watwatacrazy on Oct 21, 2008 11:06 AM
    Edited by: watwatacrazy on Oct 21, 2008 11:16 AM
    Edited by: watwatacrazy on Oct 21, 2008 11:16 AM

  • Problems with string array, please help!

    I have a String array floor[][], it has 20 rows and columns
    After I do some statement to modify it, I print this array
    out in JTextArea, why the output be like this?
    null* null....
    null null...
    null null...
    How to correct it?

    a turtle graphics applet:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TG extends JApplet implements ActionListener {
      private int x, y;
      private int pendown, command, movement;
      String direction, output, temp;
      JLabel l1;
      JTextField tf1;
      JTextArea ta1;
      String floor[][] = new String[20][20];;
      public void init()
        x = 0;
        y = 0;
        pendown = 0;
        direction = "r";
        Container c = getContentPane();
        c.setLayout( new FlowLayout() );
           l1 = new JLabel( "Please type a command:" );
           c.add( l1 );
           tf1 = new JTextField(20);
           tf1.addActionListener( this );
           c.add( tf1 );
           ta1 = new JTextArea(20,20);
           ta1.setEditable( false );
           c.add( ta1 );
    public void actionPerformed( ActionEvent e )
           temp = tf1.getText();
           if( temp.length() > 1)
           command = Integer.parseInt(temp.substring(0,1));
           movement = Integer.parseInt(temp.substring(2,temp.length()));
           else
           command = Integer.parseInt(temp);
           switch(command)
                case 1:
                pendown=0;
                break;
                case 2:
                pendown=1;
                break;
                case 3:
                direct("r");
                break;
                case 4:
                direct("l");
                break;
                case 5:
               move(movement);           
                break;
                case 6:
                print();
                break;                                     
      public void direct(String s)
           if(direction == "r" && s =="r")
              direction = "d";
           else if(direction == "r" && s =="l")
              direction = "u";
           else if(direction == "l" && s =="r")
              direction = "u";
           else if(direction == "l" && s =="l")
              direction = "d";
           else if(direction == "u" && s =="r")
              direction = "r";
           else if(direction == "u" && s =="l")
              direction = "l";
           else if(direction == "d" && s =="r")
              direction = "l";
           else if(direction == "d" && s =="l")
              direction = "r";
      public void move(int movement)
           if(pendown == 1)
                if(direction == "u")
                for(int b=0;b<movement;b++)
                     floor[x][y+b] = "*";
                else if(direction == "d")
                for(int b=0;b<movement;b++)
                     floor[x][y-b] = "*";
                else if(direction == "l")
                for(int b=0;b<movement;b++)
                     floor[x-b][y] = "*";
                else if(direction == "r")
                for(int b=0;b<movement;b++)
                     floor[x+b][y] = "*";
            else if(pendown == 0)
                 if(direction == "u")
                for(int b=0;b<movement;b++)
                     floor[x][y+b] = "-";
                else if(direction == "d")
                for(int b=0;b<movement;b++)
                     floor[x][y-b] = "-";
                else if(direction == "l")
                for(int b=0;b<movement;b++)
                     floor[x-b][y] = "-";
                else if(direction == "r")
                for(int b=0;b<movement;b++)
                     floor[x+b][y] = "-";
          public void print()
         for(int row=0;row<20;row++)
           for( int column=0;column<20;column++)
                output += floor[row][column];
                if(column == 19)
                 output+="\n";
            ta1.setText(output);
    }

  • String array operations

    Hello. I am trying to implement a method which receives a string array called SCREEN and a string called DITHERED.
    I want to check how many CHARS from DITHERED are in SCREEN.
    When I try to compile I get "An illegalaccess exception ocurred. Make sure your method is declared to be public". Any help? THANKS
    class ImageDithering
        public int count(String dithered, String[] screen)
            int num=0;
            for(int i=0;i<screen.length;i++)
                for(int j=0;j<screen.length();j++)
    for(int k=0;k<dithered.length();k++)
    if(screen[i].charAt(j)==dithered.charAt(k))
    num++;
    break;
    return num;
    }Edited by: devesa on Aug 5, 2010 9:38 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    devesa wrote:
    Hello. I am trying to implement a method which receives a string array called SCREEN and a string called DITHERED.
    I want to check how many CHARS from DITHERED are in SCREEN.Well, the method you've chosen is just about as slow as it can be.
    A few questions:
    1. Which has more characters: 'dithers' or 'screen'?
    2. Do you know about StringBuilder?
    3. Do you know about [String.indexOf()|http://download.oracle.com/javase/6/docs/api/java/lang/String.html#indexOf%28int%29]?
    4. Have you thought about sorting your strings first?
    Winston

  • Sorting string array

    Hi.
    I need a little SORT help.
    I would like to sort "f1". The file names is like this:
    number_1, number_2 ect.
    Can anybody tell me how.
    public String [] getFileList() {
    String [] f1;
    File f = new File(fpath);
    f1 = f.list();
    return f1;
    Best regards
    Soren

    Easy solution: change your naming scheme to be 2 or 3 digits (if possible)
    ie
    pic_01, pic_02 ... pic_09, pic_10
    Then the natural order of strings will take care of it for you.
    If you have more than 100 pics, you would have to do pic_001, pic_002... which would take you up to 1000.
    The not so easy solution:
    write your own java.util.Comparator to do the sorting.
    Heres an example, but it can easily break.
    It assumes that the format of the string is text_number and sorts accordingly.
    It will break if the strings don't end with _xxx
    Comparator picStringComparator = new Comparator() {
         public int compare(Object o1, Object o2) {
              String s1 = (String) o1;
              String s2 = (String) o2;
              int index = s1.lastIndexOf("_");
              String s1Prefix = s1.substring(0, index);
              int s1Number = Integer.parseInt(s1.substring(index + 1));
              index = s2.lastIndexOf("_");
              String s2Prefix = s2.substring(0, index);
              int s2Number = Integer.parseInt(s2.substring(index + 1));
              if (!s1Prefix.equals(s2Prefix)) {
                   return s1Prefix.compareTo(s2Prefix);
              else {
                   return s1Number > s2Number ? 1 : s1Number < s2Number ? -1 : 0;
    Arrays.sort(f1, picComparator);

  • TextField to String array comparison?

    Hello, I am wanting to be able to compare a users entry into a textField (single character) to the characters that are in my String array. Is this possible and how can I go about achieving it?
    My String array contains single characters in the alphabet - if a user does not type in one of these I would like to output -System.out.println("Out of Bounds");
    Thank You.

    So, to make sure I understand you, you have an array of characters that are "allowable", and if a user enters a string that has any characters that are not in the allowable set, you want an error message? If so, and starting from your code, try this:
    char[] myArray = {'a', 'e', 'i', 'o', 'u'};
    String allowable = new String(myArray);
    // I assume textFieldComponents is the user-entered String, though
    // the name doesn't really suggest that
    // Run through all characters in the user entry
    for (int i = 0; i < textFieldComponents.length(); i++) {
        // Check each character in the allowable array
        // (I assume the allowable characters array is myArray)
        if (allowable.indexOf(textFieldComponents.charAt(i)) == -1) {
         System.out.println("Out of bounds");
         break;
    }Hope that helped
    Lee

  • Problems with string arrays

    Previous task was:
    Write a class "QuestionAnalyser" which has a method "turnAnswerToScore". This method takes a String parameter and returns an int. The int returned depends upon the parameter:
    parameter score
    "A" 1
    "B" 2
    "C" 3
    other 0
    Alright, here's the recent task:
    Write another method "turnAnswersToScore". This method takes an array of Strings as a parameter, works out the numerical score for each array entry, and adds the scores up, returning the total.
    That's my code:
    class QuestionAnalyser{
    public static int Score;
    public String[] Answer;
    public static void main(String[] args) {}
         public int turnAnswerToScore(String[] Answer)
    for (int i = 0; i < Answer.length;i++) {
    if (Answer.equals("A")) {
    Score = Score + 1; }
    else if (Answer[i].equals("B")) {
    Score = Score + 2;}
    else if (Answer[i].equals("C")) {
    Score = Score + 3;}
    else {
    Score = Score + 0;}
    return Score;
    this is the error message I get:
    The results of trying to compile your submission and run it against a set of test data was as follows:
    ----------Compilation output--------------------------------------
    javac QATest2.java
    QATest2.java:15: cannot resolve symbol
    symbol : method turnAnswersToScore (java.lang.String[])
    location: class QuestionAnalyser
    if(qa.turnAnswersToScore(task)!=total){
    ^
    What went wrong?
    Suggestions would be greatly appreciated!

    If I declare int score in the method i get this message
    The results of trying to compile your submission and run it against a set of test data was as follows:
    ----------Compilation output--------------------------------------
    javac QATest2.java
    ./QuestionAnalyser.java:20: variable score might not have been initialized
    score++; }
    ^
    ./QuestionAnalyser.java:23: variable score might not have been initialized
    score++;
    ^
    ./QuestionAnalyser.java:27: variable score might not have been initialized
    score++;
    ^
    ./QuestionAnalyser.java:34: variable score might not have been initialized
    return score;
    ^
    4 errors
    ----------Sorry expected answer was-------------------------------
    The method turnAnswersToScore is working OK - well done!
    ----------Your answer however was---------------------------------
    Exception in thread "main" java.lang.NoClassDefFoundError: QuestionAnalyser
         at QATest2.main(QATest2.java:4)
    This is the message I get from the submission page, but trying to compile it I get the same messages.
    The code looks like this, then
    class QuestionAnalyser{
    String[] answer;
    public static void main(String[] args) {}
         public int turnAnswersToScore(String[] answer)
    int score;
    for (int i = 0; i < answer.length; i++) {
    if (answer.equals("A")) {
    score++; }
    else if (answer[i].equals("B")) {
    score++;
    score++; }
    else if (answer[i].equals("C")) {
    score++;
    score++;
    score++; }
    else {}
    return score;
    When I leave 'public int score;' where it was before (right after the class declaration below the declaration of the string array) I get this but it compiles normally.
    The results of trying to compile your submission and run it against a set of test data was as follows:
    ----------Compilation output--------------------------------------
    javac QATest2.java
    ----------Sorry expected answer was-------------------------------
    The method turnAnswersToScore is working OK - well done!
    ----------Your answer however was---------------------------------
    wrong answer in turnAnswersToScore for
    BDCAADDCA
    Alright, even university students need to sleep :-)
    Good night.

  • Remove null values from string array

    Hi ,
    I have a string array in a jsp page which I save some values inside. After I store the values I want to print only those who are not null. How can I do this? Is there a way to delete the null values?

    Thank you but because I am new in programming what do you mean to use continue. Can you explain it a little bit further?<%
    //go through the array to check all the values
    for(int i=0; i<array.length();i++) {
    //If array is null, nothing happen
    if(array==null){
    //leave here blank; instead use continue like:
    //this will skip the statements next to it, and increments the value of i in for loop and continues to execute the body of for loop.
    //The same will be repeated till the last iteration.
    continue;
    //If array not null, then print value in a new line
    else{
    out.print(array+"<br>"); //don't change the logic here
    %>

  • Getting one character at a certain position from a string array

    Hi, i'm new at learning java, but have strong experience at C++ and asm. How would i get one character at a certain positon from a string array.
    for example:
    String Phrases[] = {"To be or not to be, that is the question","The Simpsons","The Mole","Terminator three rise of the machines","The matrix"};
    that is my string array above.
    lets say i wanted to get the first character from the first element of the array which is "T", how would i get this

    ok well that didn't work, but i found getChars function can do what i want. One problem, how do i check the contents of char array defined as char Inchar[];

  • How to add elements into java string array?

    I open a file and want to put the contents in a string array. I tried as below.
    String[] names;
    s = new Scanner(new BufferedReader(new FileReader("outfile.txt")));
    while (s.hasNext()) {
                    String item = s.next();
                    item.trim();
                    email = item;
                    names = email;
                }But I know that this is a wrong way of adding elements into my string array names []. How do I do it? Thanks.

    Actually you cannot increase the size of a String array. But you can create a temp array with the lengt = lengthofarray+1 and use arraycopy method to copy all elements to new array, then you can assign the value of string at the end of the temp array
    I would use this one:
    String [] sArray = null;
    s = new Scanner(new BufferedReader(new FileReader("outfile.txt")));
    while (s.hasNext()) {
        String item = s.next();
        item.trim();
        email = item;
        sArray = addToStringArray(sArray, email);
    * Method for increasing the size of a String Array with the given string.
    * Given string will be added at the end of the String array.
    * @param sArray String array to be increased. If null, an array will be returned with one element: String s
    * @param s String to be added to the end of the array. If null, sArray will be returned.(No change)
    * @return sArray increased with String s
    public String[] addToStringArray (String[] sArray, String s){
         if (sArray == null){
              if (s!= null){
                   String[] temp = {s};
                   return temp;
              }else{
                   return null;
         }else{
              if (s!= null){
                   String[] temp = new String[sArray.length+1];
                   System.arraycopy(sArray,0,temp,0,sArray.length);
                   temp[temp.length-1] = s;
                   return temp;
              }else{
                   return sArray;
    }Edited by: mimdalli on May 4, 2009 8:22 AM
    Edited by: mimdalli on May 4, 2009 8:26 AM
    Edited by: mimdalli on May 4, 2009 8:27 AM

  • Exporting a String Array to an HTML file

    Hey everyone..I'm currently making lots of progress in my project...but right now I've been trying to make a button that exports my search results to an html file...basically what I've made is a search engine to search webcrawler files...
    The result list I get (which is actually a string array), I want to export to html so I can open that html file and find all the links that were found in the search I made..What I have so far is this, but it's not working yet, any help? :
        private class exportListener implements ActionListener
            public void actionPerformed(ActionEvent e)
                String[] result = parent.getResult();
                if(result == null)
                    return;
                JFileChooser chooser = new JFileChooser();
                chooser.setAcceptAllFileFilterUsed(false);
                chooser.setFileFilter(new HtmlFileFilter());
                chooser.setDialogType(JFileChooser.SAVE_DIALOG);
                int returnVal = chooser.showSaveDialog(parent);
                if(returnVal == JFileChooser.CANCEL_OPTION)
                    return;
                File fl = chooser.getSelectedFile();
                String path = fl.getPath() + ".html";
                searchIF.exportResultAsHtml(path);
                System.out.println(path);
        private class HtmlFileFilter extends FileFilter
            public String getDescription(){return "Html";}
            public boolean accept(File pathname)
                String name = pathname.getPath();
                //Just checking to see if the filename ends with html.
                if (name.toLowerCase().substring(name.lastIndexOf('.') + 1).equals("html"))
                    return true;
                return false;
            }

    Actually..nevermind, sorry.

  • How to populate items in selectOneListBox from a string array

    Hi
    I have got a string array result[] .Now i wish to display the array items in selectOneListBox.Please help me?

    Alance wrote:
    Hi
    I have got a string array result[] .Now i wish to display the array items in selectOneListBox.Please help me?I can only guess what your selectOneListBox is but if it is JComboBox - have you ever thought about reading the API ?
    [http://java.sun.com/javase/6/docs/api/javax/swing/JComboBox.html]
    There's a wonderful constructor which probably does what you are looking for.

  • How to use a WebService Model with String Arrays as its input  parameter

    Hi All,
    I am facing the following scenario -
    From WebDynpro Java i need to pass 2 String Arrays to a Webservice.
    The Webservice takes in 2 input String Arrays , say, Str_Arr1[] and Str_Arr2[] and returns a string output , say Str_Return.
    I am consuming this WebService in WebDynpro Java using WEB SERVICE MODEL. (NWDS 04).
    Can you please help out in how to consume a WSModel in WD where the WS requires String Arrays?

    Hi Hajra..
    chec this link...
    http://mail-archives.apache.org/mod_mbox/beehive-commits/200507.mbox/<[email protected]>
    http://www.theserverside.com/tt/articles/article.tss?l=MonsonHaefel-Column2
    Urs GS

  • Trying to compare string array using equals not working

    Hi,
    im prolly being really dumb here, but i am trying to compare 2 string arrays using the following code:
    if(array.equals(copymearray))
    System.out.println("they match");
    else
    {System.out.println("dont match");}
    the trouble is that even though they do match i keep getting dont match, can anyone tell me why?

    try
    if (Arrays.equals(array, copymearray))
    System.out.println("they match");
    else
    {System.out.println("dont match");}

  • Getting lenght of String array

    Hi,
    How can i find the lenght of a string array, i have used length method to calculate length of single string value,e.g
    String value = "test"
    int length = value.length()
    Now i want to calculate length of a string array.e.g
    String csv_values = "test,by,random"
    String[] str = csv_values.split(",")
    int lenght = str.length()
    As you can see i want to calculate total number of entries in an array after i split it dynamically.
    Currently it is giving me exception, "Unable to parse exception; Undefined method: length for class: [Ljava.lang.String]"
    Thanks

    This is a tricky one.  An Array has a length property, unlike a String which has a length method.
    So...
    int length = str.length
    Anthony Holloway
    Please use the star ratings to help drive great content to the top of searches.

Maybe you are looking for

  • IPhone 4 not recognized by iTunes 10.1.1

    I am running 10.6.6 and 4.2.1 and when I plug in my iPhone 4 to sync with iTunes nothing happens, it is not recognized. If I open iPhoto it finds the phone and I am able to sync photos. This is getting ridiculous, this is probably the fifth time this

  • MIRO Not Shows Amount In Local Currency

    HI My Service PO is in USD.  Goods Receipt is Alos Posted in USD. But at the Time of MIRO when i simulate the Transaction and Check the Document in Local Currency System Do not show me INR amount in Vendor Item. It Shows Zero Balance. Due to this I a

  • Performance issue: Follow up transaction creation taking too much time

    hi, i am facing an issue where whenever a user tries to create a follow-up Quote from an opportunity, it is taking more than 7-8 secs...can someone help me understand its a standard time or ways to reduce the time taken. we have already implemented S

  • Oracle 11gR2

    i have a solaris SPARC 10 64 bit box...and downloaded 11Gr2 SPARC64 from oracle, and only when installing i found that my kernel version is not supported. when i did a search for compatiblity matrix for kernel version, it didnt turn up any result. ex

  • Duplicate IR through parallel processing for automated ERS

    Hi, We got duplicate IR issue in production when running the parallel processing for automated ERS job. This issue is not happening in every time. Once in a while the issue happeing. That means the issue has happened in June month as twice. What coul