ArrayList<String> nameList = new ArrayList<String>();
nameList.add("James");
nameList.add("Joe");
nameList.add("Josh");
nameList.add("Bob");
nameList.add("Billy");
System.out.println("The names are:\n " + nameList);
nameList.remove(1);
System.out.println("Find the index 1 and remove their name from the list:\n "+ nameList);
nameList.size();
System.out.println("Currently the ArrayList holds " + nameList.size() +
" names after removing the name of index 1" );
String[] tempArray= new String[nameList.size()];
tempArray = nameList.toArray(tempArray);
System.out.println(tempArray); // I want it to display the values of the ArrayList
}
}
The output I'm getting is [Ljava.lang.String;@4554617c when I want it to look like this [James, Josh, Bob, Billy]. New to programming would appreciate the help.