How to Declare a Long Variable

Long was added in API Level 1
The wrapper for the primitive type long.
The long data type is 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, you can use the long data type to represent an unsigned 64-bit long, which has a minimum value of 0 and a maximum value of 264-1. The unsigned long has a minimum value of 0 and maximum value of 264-1. Use this data type when you need a range of values wider than those provided by int.

1. In the MainActivity.java file, add the below line to the onCreate method. This will create a long variable named myLong.

long myLong;