Java code has various commonly accepted conventions. These are important in allowing your own code to be read easily by others and for you to understand code someone else has written as quickly as possible.

Some of the most important conventions are:

Java variable names begin lower case and are in camel case.
Class names begin upper case and are in camel case. They are nouns. For further information see The Oracle code convention guide

When it comes to Java classes, the following sets out the conventions for proper encapsulation and use of accessors/mutators (getters/setters). This is particularly important where objects are serialized.

public class Foo {
    private int bar;

    public Foo() {

    public Foo(int bar) { = bar;

    public int getBar() {

    public void setBar(int bar) { = bar;

    public String toString() {
        return String.format("%s=%d""bar", bar);