Please refer to the following code:
Scanner scan = new Scanner(System.in);
int T = Integer.parseInt(scan.nextLine());
StringBuilder []str = new StringBuilder[T];
String temp = new String();
for (int i=0; i < T; i++){
temp = scan.nextLine();
str[i].append(temp);
}
System.out.println(str);
The above code throws a Null Pointer Exception on the line:
str[i].append(temp);
I want to do it with StringBuilder.