Create an Integer Variable

How to Create an Integer Variable

This will declare an integer variable

Integer was added in API Level 1

An integer is a number from -2147483648 to 2147483647. The integer data type is a 32-bit signed two's complement integer. Integer is generally used as the default data type for integral values unless there is a concern about memory. The default value is 0.

1. Create an Android project, if you don't already have one.

2.In the MainActivity.java file, add the code below to the onCreate method. This will create an integer variable named myInteger

    int myInteger;

3. Compile and run!

Next Recommended Article: Set an Integer Variable

Related Articles: