Data type [] Array name = {};
String[] names = {"tanaka" , "sato" , "suzuki"};
System.out.println(names[0]);
Output all the contents of the array.
** Normal for statement **
String[] names = {"tanaka" , "sato" , "suzuki"};
for(int i = 0; i < names.length; i++) {
System.out.println(names[i]);
}
** Extended for statement **
for (data type variable: array name) {}
String[] names = {"tanaka" , "sato" , "suzuki"};
for(String name:names) {
System.out.println(name);
}
Recommended Posts