What is Syntax Mode (the "what are you writing" dropdown)?

  • Expression

    This mode is useful if you just want to execute a single expression. Some examples are:

    // calculate a 15%
    // tip for a $43 meal
    43 * 0.15
  • Method

    This mode is useful if you are working on a more complex task that consists of more than one expression. To output the results of your code, simply wrap the object that you want to display in a call to $(...). Below are some examples:

    int x = 40;
    int y = 180;
    $(x + y); // prints 220
    $(x - y); // prints -140
    $(x * y); // prints 7200
  • Program

    This mode is useful if you are working on a task which may require additional methods or classes.

    void main() {
        MyHelperClass helper =
            new MyHelperClass();
        $(helper.helpMe());
        $(helper.today());
    }
    
    class MyHelperClass {
        public String helpMe() {
            return "Help ME!!!";
        }
    
        public Date today() {
            return new Date();
        }
    }

How can I dump an object to output?

There are 2 ways to dump an object. They are synonymous, one is a shorthand of the other. Here they are: UserUtils.show(...), and $(...). The object will be dumped to an HTML table. You can copy and paste the table into a spreadsheet program, and it will recognize and correctly place values into separate cells.

Can I use System.out.println(...)?

Yes, you can. You can also use any of the other output methods available in System.out.

Can I import external jars? Can I add import statements?

Yes, you can. Click the Snippet Imports button in the tool bar, or use the default keyboard shortcut of F4.

In the top part of the Imports dialog, you can browse to an external jar file.

In the bottom part of the Imports dialog, you can list additional package imports, one per line. You don't need to prefix the package name with the word import. For example:

javax.swing.JTable
java.util.stream.*

What kind of settings are there?

  • JDK location

    You can browse for a specific location of the JDK. This is useful if you have multiple versions installed and want to compile using a specific version of Java. Changing the JDK location requires a restart of the editor.

  • Theme

    littleJ support 2 themes - Light, and Dark. Pick your preference.

  • Starting Syntax Mode

    You can pick which syntax mode you would like littleJ to start in. If you write more expressions than programs, change this setting accordingly.