I am confused as to how the Java String class default constructor converts the char array into String.
char c[]= {'H', 'E', 'L', 'L', 'O'};
String s= new String (c, 0,3);
System.out.println(s) ;
Gives output as - HEL
In this case, the last character is taken as endIndex - 1.
char c[]= {'H', 'E', 'L', 'L', 'O'};
String s= new String (c, 1,3);
System.out.println(s) ;
Gives output as - ELL
But, in this case, the last character is taken as endIndex only.
What's happening here?