2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by manish250
0

what i mean is string is a mobile no which is entered by user.i want to check the length of it so that arrayIndex out of bound exception can be handled.that why i want fetch enterd moblie no and check it's length.
what i m using for this is

if(length > 12)
        {                //*354*4*9061239405#
                 strRequest = strRequest.substring(7,length-1);
                System.out.println(strRequest);
        }

but sometime when user enter *354*4*96034# then it will give Indexoutof bound exception.I want to print some error message instead of this

0

Then take the length of the String and use if-else statements as when to call the substring method. The variable length, how do you give it value? Shouldn't be using the String API in order to get the length of the String ?

This question has already been answered. Start a new discussion instead.
Be sure to adhere to our posting rules.