Question

I used to program on BlueJ for school, but now I'ld like to try NetBeans for personnal usage.

In BlueJ, we can see all the created objects. On this objects, we can see all the fields and their values. We can even call one single method of the class on this object. We also can run a single static method of the class, without running the entire file.

Is there a way to do the same on NetBeans ? This functionnality of BlueJ is very convenient.

I apologize if I am not clear, tell me if you can't see what I mean.

Was it helpful?

Solution 2

To see what objects are created and their values in NetBeans, you can run your code in the debugger. Here's a tutorial on adding a watch in NetBeans that teaches you how to view the type and value of variables.

To run a method of a class, I'd recommend setting up a unit test (see Testing and Code Analysis). It's a little bit more work to set up than BlueJ's facility for running methods on the fly, but it's worth it because you can easily run the same tests repeatedly and even automate testing.

OTHER TIPS

Unfortunately, no. I am not aware of any way to view objects in NetBeans the same way as you can with BlueJ, nor run a single static method of a class.

you can check it by another way by putting a print statement like:

if (x=1){

    DoSomething();
    System.out.println("yes, x = 1 !");
}
else{

    SendError();
    System.out.println("No, x Not Equals 1 !");
 }

If Really x = 1 , you will see the output of the program "yes, x = 1 !". If not you will see the another statement "No, x Not Equals 1 !".

You can also check if the user entered any method or not by the print statement !

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top