String str = "Nobody ever went broke by buying IBM";
System.out.println("Length of this string: "+ str.length());
System.out.println("The character at position 36: "+ str.charAt(36)); // i get error here
System.out.println("The substring from 36: "+ str.substring(36));// why no error here
I get output as follows :
Length of this string: 36
The character at position 36: error
The substring from 36:
My question is why it is not showing error when when substring(36) is called, instead i am getting answer as empty space. Logically there is no char at index 36?? But i get error when i call charAt(36) because there is no 36 index ??