Search:

Type: Posts; User: javapenguin

Search: Search took 0.08 seconds.

  1. Replies
    19
    Views
    2,052

    Re: need help with 2D array

    The problem is that sometimes I, like others, don't know we're doing it wrong.

    I didn't realize I could get kicked out for giving advice, especially advice that seems to make sense to me at the...
  2. Replies
    19
    Views
    2,052

    Re: need help with 2D array

    String rollNumber = console.nextLine();

    String number = rollNumber.substring(3);

    Where do you want them stored at in the array?
  3. Replies
    19
    Views
    2,052

    Re: need help with 2D array

    Also, I don't know what:

    System.out.print("Enter the size of the array s: ");
    size = scan.nextInt();
    System.out.println("size is :" + size);
    String[][] arr = new...
  4. Replies
    19
    Views
    2,052

    Re: need help with 2D array

    It should be

    System.out.println(rollnumber.split("IAD")[0]);

    I see now that the 0 would be index 0 of the array the split method is creating.
  5. Replies
    19
    Views
    2,052

    Re: need help with 2D array

    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
  6. Replies
    19
    Views
    2,052

    Re: need help with 2D array

    Doesn't seem right to me, with the [] around the 1.

    If anything, it'd be split("IAD", 1);

    Actually, it could be

    System.out.println(Arrays.toString(rollnumber.split("IAD", 1)));
  7. Replies
    19
    Views
    2,052

    Re: need help with 2D array

    Also, your for loop will change letter found the first time it finds the letter and it'll still be true for the next iteration of your for loop.
  8. Replies
    19
    Views
    2,052

    Re: need help with 2D array

    System.out.println(rollnumber.split("IAD")[1]);

    You're printing an array?

    Also, I'm positive that's invalid syntax.

    It's

    public String[] split(String regularExpression)
    {
Results 1 to 8 of 8