Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Help Java L The long keyword

Related Tutorials


Share on Google+Share on Google+

The long keyword

long is a keyword in java that is used to store 64-bit integer (Java primitive type) value.

The long keyword


long is a keyword in java that is used to store 64-bit integer (Java primitive type) value. Keywords are basically reserved words which have specific meaning relevant to a compiler. The keyword long in java is also used to declare an expression, method return value, or variable of type long integer. The Long class in java programming language wraps a long type primitive value in an object. An Long type object includes only a single field whose type is long. Wrapper class is used to convert the long primitive values into Long type objects. In addition to this Long wrapper class also provides methods for converting a long to String and vice versa as well as other constants and methods that are useful to deal with long type.

Syntex:  Here is the syntax that displays how to declare and define a long type variable.

long number = 5;

Here are some more examples.

long anotherNumber = 34590L;

long octalNumber = 0377;

long hexNumber = 0xffl;

Note: Here are some points that must consider in case of long data type.

  • The Long class in java programming language is a wrapper class in order to support the long primitive type. Constants MIN_VALUE and MAX_VALUE are used to represent the range of values for this type.

  • In java programming language all integer literals are 32−bit int values unless the value is followed by l or L as in 235L, which specifies that the value should be interpreted as a long.



If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 18, 2008

Related Tutorials

Discuss: The long keyword  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image