0
Code
Public class my{ Public Static void main(String []args){ String g= âHello i love javaâ; Int start=2; Int end=9; Char s[ ]=new char[end-start]; g.getchars(start,end,s,0); }} Output is: llo i l Iam not understanding why ?
4 Answers
+ 1
s is an array of 7 characters.
with g.getchars() method, s is assigned to the characters of g index ranging from start to end.
in the output first 'l' corresponds to the char with index 2 in g, same way, last 'l' corresponds to the char with index 8.
0
it copies chars form position 2 to 9 (except 9)
String g = "He llo I l ove java";
// 01 2345678 90123456
public class my {
public static void main(String []args){
String g = "Hello I love java";
int start =2;
int end =9;
char[] s = new char[end-start];
g.getChars(start, end, s, 0);
System.out.println( s );
}
}
0
from g.getchars(start,end,s,0);
how we get llo i l ??
0
Indian explanation is already given by @zemiak.
From string g, it copies charecters from start index (2) to end-1 (9-1=8, end not inclusive) index.. into the s charecter array...



