Trying out Code in BlueJ

Premium Content - Free Preview

While the previous node demonstrated trying things out with BlueJ's visual interface, this node will cover trying things out in code.

Trying Out Code
It is often convenient to quickly try out code without having to put it into a whole program and compile it. However, since Java is a Compiled Language, it doesn't come with a built-in "tryer-outer". BlueJ solves this issue by providing a CodePad for this purpose.

The Codepad

The codepad should be visible on the bottom right corner of BlueJ. If it isn't, click on View > Show Codepad.

Using the Codepad
To evaluate an expression in Java, just type it into the codepad and hit "enter" . Don't put a semicolon at the end of the line. For example:

2   (int)
 5   (int) 

You can also access objects that were created earlier in the codepad, or on the Object bench. For example, if you created a Student student1 earlier, you could type:

 "ID 00234"   (String)

End of Free Content Preview. Please Sign in or Sign up to buy premium content.


  • I'm stumped on this one. I got the answer 20825, but it says this is incorrect. Maybe I misinterpreted the question? This is my code (compiled and verified in an IDE):
    class Example {

  • @Victoria, 1 to 50 only contains 26 odd numbers (see the hint).

  • Thanks, I've got it now. I may well take up the offer of membership in future - I'll see how I get on for now.

  • 166650

  • This worked just fitne

    int sum=0;
    for (int i=1;i<100;i=i+2){sum=sum+i*i;}

  • It just keeps saying: Error, ";" expected

Contact Us
Sign in or email us at [email protected]