FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 256   



Variable holds the value during the program execution.
Following is the syntax for declaring a Variable

type identifier;

ex:

int i;

Following is the syntax for Initialization

identifier = value;

ex.

i = 10;

You can do these two things in one line

int i = 10;

Let me show you a program to declare & initialize all primitive data types of Java

public class PrimiteDataTypes {

    public static void main(String[] args) {

        byte byteVal = 127;
        short shortVal = 32767;
        int intValue = 2147483647;
        long longValue = 9223372036854775807L;

        float floatValue = 1.5F;
        double doubleVaue = 12.678;

        char charValue= 'f';

        boolean booleanValue = true;

    }
}



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News