Java Keyword Long

The reserved keyword long is used to define a variable as a numeric data type. A keyword long data type is a 64 bit two’s complement integer. The signed long has a minimum value of -9223372036854775808L (negative) and a maximum value of 9223372036854775807L (positive).

Let’s declare a long variable and initialize it with a value. You will notice that it’s completely okay to use either a lower case ‘l’ or an upper case ‘L’ as part of the initialization of the long.

//JavaCodeDepot Sample 

long jcdLong1 = 123456789l;
long jcdLong2 = 987654321L;


You can also use the long keyword when you define a function or method that returns a long data type.

//JavaCodeDepot.com Sample

public long javaCodeDepotAwesomeMethod() {

    long jcdLong = 564123468L;
    //Do some actions....
    
    return jcdLong;

}


The long is one of the eight primitive data types defined by Java.

The complete list of Java reserved keywords contains a total of 50 keywords and 3 literal words that are unable to be used as variable names.

Add a Comment

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