0
Why do I get a weird output for this code?
public class Program { public static void main(String[] args) { String[ ] myNames = { "A", "B", "C", "D"}; System.out.println(myNames); } }
1 Answer
+ 1
It's the data structure you chose.
If you add the index, it may show correct answer, but the full data (myNames) isn't what you see.
Look this to get a better overview:
public class Program {
public static void main(String[] args) {
String[ ] myNames = { "A", "B", "C", "D"};
String str = String.join("", myNames);
System.out.println(str);
}
}