[Solved] Java code output is weird?


When you say

System.out.println(person[0]);

java doesn’t automatically know what you want printed out. To tell it, you write a method in your Examples class called toString() which will return a string containing the info you want. Something like:

@Override
public String toString() {
    return "Name: " + name + 
           " Age: " + String.valueOf(this.age) + 
           " Gender: " + String.valueOf(this.gender); 
}

0

solved Java code output is weird?