The long data type represents a 64-bit two’s complement integer. The signed long has a minimum value of -263 and a maximum value of 263-1. In Java SE 8 and later, it represent an unsigned 64-bit long, which has a minimum value of 0 and a maximum value of 264-1.
Range: -9223372036854775808 to 9223372036854775807.
Program to declare and use Java primitive long variable.
import java.util.Date; /** * Program to declare and use Java primitive long variable. * @author W3spoint */ public class DataTypeLongExample { public static void main(String args[]){ //Declare long type variables. long l1 = new Date().getTime(); //Print variables value. System.out.println("l1 Value: " + l1); } } |
Output:
l1 Value: 1449573637803 |