WHAT IS THE DIFFERENCE BETWEEN DECLARING A VARIABLE AND DEFINING A VARIABLE?

Mayank Tripathi

Total Post:807

Points:4035
Posted by  Mayank Tripathi
Java 
 508  View(s)
Ratings:
Rate this:
  1. Mayank Tripathi

    Post:807

    Points:4035
    What is the difference between declaring a variable and defining a variable?

    In declaration we just mention the type of the variable and it's name. We do not initialize it. But defining means declaration + initialization.

    e.g String s; is just a declaration while String s = new String ("abcd"); Or String s = "abcd"; are both definitions.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!