I'm still learning Java and I was wondering how can I access an element of an array? For example, I have this array:
private int[] employeeNum={5658845, 4520125, 7895122, 8777541, 1302850, 7580489};
And I want to display the number "450125" while using a for loop. What should I do? Also, if you have a better method rather than a for loop, please feel free to put it; it would be much appreciated. I'll put in the for loop I'm using just in case :
for(int i=0; i<6; i++) {
System.out.println("Enter the hours worked by employee number " +
employeeNum[i] + ":");
}
import java.util.Arrays; System.out.println( Arrays.toString(employeeNum) );