2 Replies Latest reply: Mar 31, 2007 12:39 PM by 807599 RSS

    string index out of bounds... issue regarding checking for non-integers

    807599
      okay. i have been racking my brain about this for the last couple of days. i looks like everything is alright, but i keep getting string index out of bounds exception: string index out of range 1.

      heres the code.

                     for(int x=0; x<size; ++x)
      {
                          count=x+1;
                          System.out.println("Please enter value #"+count+(":"));
                          numnum=console.nextLine();
                          
                          if(Character.isDigit(numnum.charAt(x)))
                               goodInput=true;
                          
                          if(!goodInput)
                               System.out.print("Please Enter Only Integers!");
                          
                          else
                               values[x]=Integer.parseInt(numnum);
                     }

      its probably something really stupid, but if someone can figure this out, id be most grateful.
      -thanks