lovespring
lovespring

Reputation: 19589

How to show java object content in eclipse console, just like javascript console.dir()?

I want show the content of my java object in eclipse console, just like debugging in chrome, and show JavaScript object in chrome console use the console.dir();

Upvotes: 2

Views: 1284

Answers (2)

Suresh Atta
Suresh Atta

Reputation: 122006

Just Ovveride the toString() method of your Object and construct your String there in whichever format you like, For ex

@Override
    public String toString() {
        return "Objname{" + "property1=" + value1+ ", 
               prop2=" + val2+ ", 
               prop3=" + val3+ '}';

    }

then simply

System.out.println(object.toString());

Upvotes: 1

Eran
Eran

Reputation: 393966

Run your code with a debugger, and watch whatever object you need to.

Upvotes: 1

Related Questions