I am having trouble displaying an array by index, I don't know why this is happening. Any help will be greatly appreciated. Here is a snippet of my code:
// create token2
String token2 = "";
// create Scanner inFile2
Scanner inFile2 = new Scanner(new File
("/Users/timothylee/KeyWestHumid.txt")).
useDelimiter(",\\s*");
// create temps2
List<String> temps2 = new LinkedList<String>();
// while loop
while(inFile2.hasNext()){
// find next
token2 = inFile2.next();
// initialize temps2
temps2.add(token2);
}
// close inFile2
inFile2.close();
// create array
String[] tempsArray2 = temps2.toArray(new String[0]);
// for-each loop
for(String ss : tempsArray2){
// display ss
System.out.println(tempsArray2[0]);
}
I am having trouble displaying an array by index, I don't know why this is happening. What's thetrouble, what's thedisplay, and what ishappening?System.out.println(ss);