Hello,
First element (Zero element) in myString array always is null. Why?
Thanks
import java.util.*; class MainClass { public static void main(String[] args) { Scanner S = new Scanner (System.in); int num = S.nextInt(); String[] myString = new String[num]; for (int i = 0 ; i < num ; i++) { myString[i] = S.nextLine(); } String[] MY = null; for (int i = 0 ; i < num ; i++) { MY = myString[i].split(" "); for(int j = 0 ; j < MY.length; j++) { char[] myChar = MY[j].toCharArray(); if (myChar[0] >= 97 && myChar[0] <= 122) { myChar[0]-=32; } MY[j] = new String(myChar); } myString[i] = String.join(" ", MY); } for (int i = 0 ; i < num ; i++) { System.out.println(myString[i]); } } }