Variable declaration, definition, and initialization

Let's look at the examples first. Let's assume we have these three lines of code consecutively:

int x;  //declartion of variable x
x = 1; //initialization of variable x
x = 2; //assignment of variable x

As you can guess from the preceding example, variable initialization is assigning the first (initial) value to a variable. All subsequent assignments cannot be called an initialization.

A local variable cannot be used until initialized:

int x;
int result = x * 2; //generates compilation error

The second line of the preceding code will generate a compilation error. If a variable is a member of a class (static or not) or a component of an array and not initialized explicitly, it is assigned a default value that depends on the variable's type (see the Primitive types and literals and Reference types and String sections). 

A declaration creates a new variable. It includes the variable type and name (identifier). The word declaration is a technical term used in the Java Specification, section 6.1 (https://docs.oracle.com/javase/specs). But some programmers use word definition as the synonym for declaration because the word definition is used in some other programming languages (C and C++, for example) for a type of statement that does not exist in Java. So, be aware of it and assume they mean declaration when you here definition applied to Java.

Most of the time, when writing Java code, programmers combine declaration and initialization statements in one.  For example, a variable of the int type can be declared and initialized to hold integer 1, as follows:

int $ = 1;
int _1 = 1;
int i3 = 1;
int αρετη = 1;
int String = 1;
int MAX_VALUE = 1;
int isLetterOrDigit = 1;

The same identifiers can be used to declare and initialize a variable of the String type to hold abs:

String $ = "abc";
String _1 = "abc";
String i3 = "abc";
String αρετη = "abc";
String String = "abc";
String MAX_VALUE = "abc";
String isLetterOrDigit = "abc";

As you may have noticed, in the preceding examples, we used the identifiers from the examples of the Identifier section.