In java primitive variables will get its default value automatically after declaration. Then why it is mandatory to initialize a variable before using it.
When you declare a variable in Java, it is initialized with a default value according to the type of the variable. This is applicable only to instance and class variables which are declared inside a class and outside any method in the class. Local variables are not given default initial values which are declared inside a method. They must be initialized explicitly before they are used.
Initialization of a variable is to keep it free from any junk value.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.