All Java codes are defined in a Class. It has variables and methods.

Variables are attributes which define the state of a class.

Methods are the place where the exact business logic has to be done. It contains a set of statements (or) instructions to satisfy the particular requirement.

Example:

public class Addition{ //Class name declaration
int a = 5; //Variable declaration
int b = 5;
public void add(){ //Method declaration
int c = a+b;
}
}