anirban nag wrote:when i'm running this code in jcreator it's showing :
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
but when i'm running this in command promt there are no exception or error why??
The only thing I can guess is that either
1. Whatever console jcreator uses isn't connected to System.in (seems odd; but I've never used the product).
2. You aren't entering a character.
Specifically, you need to make sure that
line2.length() is > 0
before you try
line2.charAt(0).
BTW, '
line2' is not a very good name.
Winston