2(ii)
Write the output of the following String method:
String x = "talent"; String y = "matrix"; System.out.println(x.substring(3).concat(y.substring(3)));
Show SolutionHide Solution↓
entrix
x.substring(3)returns the substring of"talent"from index 3 onwards, i.e.,"ent".y.substring(3)returns the substring of"matrix"from index 3 onwards, i.e.,"rix".- The
concat()method joins both substrings:"ent"+"rix"="entrix".