String[] initialized by null???
- by Esmond
Hi i encountered this problem whereby when i initialized my String[], there seems to be a null in the String[] before i do anything. How do i initialized the String[] to be completely empty,i.e. without the null at the start?
The output for the following code is:
nullABC
nullABC
nullABC
nullABC
nullABC
public static void main(String[] args){
String[] inputArr = new String[5];
for (int i = 0; i< inputArr.length; i++){
inputArr[i] += "ABC";
}
for (int i = 0; i< inputArr.length; i++){
System.out.println(inputArr[i]);
}
}
}