Home > DeveloperSection > Interviews > What is the difference between declaring a variable and defining a variable?

Posted on    July-24-2015 11:09 PM

 Java Java 
 1 Answer(s)
  470  View(s)
Rate this:

Mayank Tripathi
Mayank Tripathi

Total Post:807

Posted on    July-24-2015 11:09 PM

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.

Don't want to miss updates? Please click the below button!

Follow MindStick