I'm trying to use a nested for-each loop to print out the names in the two dimensional array but it's printing out "[Ljava.lang.String;@15db9742" instead and I don't understand why. is there another way to print out the both array using a nested for each loop?
public static void main(String[] args)
{
String[][] str =
{{"Steve", "Rick", "John"},{"Erick","Bob","Dave"}};
for(String[] s :
str){
for(String e : s){
System.out.println(s);
}
}
}
}
// Note: print value of 'e' instead of variable 's' //////////////////////////////////////////// //TestCode.java public class TestCode { public static void main(String[] args) { String[][] str = {{"Steve", "Rick", "John"},{"Erick","Bob","Dave"}}; for(String[] s : str){ for(String e : s){ System.out.print(e+" "); } System.out.println(); } } }
Get Answers For Free
Most questions answered within 1 hours.