Here is our character array.
char[] ch = { 'T', 'E', 'S', 'T', 'I', 'N', 'G'};
Create string object from some part of a string using the following String constructor. Through this we are fetching substring “IN” from the character array.
String str = new String(ch, 4, 2);
public class Demo { public static void main(String[] args) { char[] ch = { 'T', 'E', 'S', 'T', 'I', 'N', 'G'}; String str = new String(ch, 4, 2); System.out.println(str); } }
IN