Data Types Default Values Java

Data Types Default Values Java


Java does not support garbage values. An unassigned local variable gives compilation error and an instance (global) variable takes a default value. Following program illustrates the default values given by JVM for unassigned instance variables.

String is not a data type. If not assigned, String takes null as the default.

Data Types Default Values Java

Observe the screenshot on Data Types Default Values Java. The default values for whole numbers is 0, for floating-point numbers is 0.0 and for primitive data type boolean it is false. String takes null and char does not print any value. Actually, it prints a value equivalent to Unicode value of /u0000 which prints nothing.

14 thoughts on “Data Types Default Values Java

  1. charusheela

    Think you sir for your guidence. I like your explanation with simple example, which i understand very fast and remember it easilly.

    thank you! thank you!! thank you!!!

  2. sneha

    sir ,this website is very useful for us .i have sugested this website to many and all are saying so.
    sir one more thing can u upload the same kind of website for c and c++ also

  3. Anuradha

    This site is very helpful for us to learn everything very easily Sir.Thank you for developing such a nice site.Thanks alot Sir.

Leave a Reply

Your email address will not be published. Required fields are marked *