I hope you can better understand with this example:

I hope you can better understand with this example:

Java's substring inputs,
public String substring(int beginIndex,int endIndex)
beginIndex - the beginning index, inclusive.
endIndex - the ending index, exclusive.
Note the exclusive. substring(0,1) will return a string including character 0, up to but NOT including character 1.
Source: http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#substring(int, int)
The String.substring() methods do not examine the content of the substring, so what you are describing is likely a bug in your code. You can post the minimal amount of code necessary to reproduce the problem if you'd like some help troubleshooting.
Given the code and information given in the update and comments, this is what I'd expect:
String actnum = "03KL352"; /* Maybe actnum is actually entered via a JSP. */
System.out.println(actnum); /* Prints 03KL352 */
String ccode = actnum.substring(1,2); /* Assign characters [1,2) to ccode. */
System.out.println(ccode); /* Prints 3 */
Remember, Java's string indexes are zero-based. The first character is at index 0, the next at index 1. Also, the substring method takes two character indexes; the first is included in the new substring, the second is not—it is the index of the character after the last character in the new substring. So, the length of the new substring is end - start.
Based on the code that you have in the question, you probably want the first two characters of the string. Assuming this to be the case, then the code that you want is:
ccode = actnum.substring(0,2);
The Javadoc for substring states that it returns the characters from the index specified by first argument up till, but not including, the index specified by the second argument.
The first two characters of the string would be actnum.substring(0,2). The first argument is 0-based. The second argument is also 0-based, but is not included in the result.
According to the Java API doc, substring throws an error when the start index is greater than the Length of the String.
IndexOutOfBoundsException - if beginIndex is negative or larger than the length of this String object.
In fact, they give an example much like yours:
"emptiness".substring(9) returns "" (an empty string)
I guess this means it is best to think of a Java String as the following, where an index is wrapped in |:
|0| A |1| B |2| C |3| D |4| E |5|
Which is to say a string has both a start and end index.
When you do foo.substring(5), it gets the substring starting at the position right after the "e" and ending at the end of the string. Incidentally, the start and end position happen to be the same. Thus, empty string. You can think of the index as being not an actual character in the string, but a position in between characters.
---------------------
String: | a | b | c | d | e |
---------------------
Index: 0 1 2 3 4 5