Java Java Objects Meet Objects Methods

Hashcode is printed

Hi i have an issue here.

Whenever i try to print something the hashcode of the String is also pritned eventhough i made a toString method.

take a look:

public class Test {

public static void main(String[] args) {

    test1 yoda = new test1();
    yoda.toString();

    System.out.println(yoda);
}

}

public class test1 { String yoda = "Yoda"; }

1 Answer

Wil Arter
Wil Arter
1,369 Points

Hi Kristoffer,

You are trying to convert the object to a string instead of doing that you will need to do yoda.yoda and this should fix it.