2

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();

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

this is what I know, is there any simple way to dump the object in console ?
@lovespring Dump what object? Your program probably has multiple objects. And when do you want to dump it? You usually examine the contents of your objects when running your program in a debugger. This way you can view whatever object you wish, whenever you pause the execution of the program.
1

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());

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.