Java int keywordThe Java int keyword is a primitive data type. It is used to declare variables. It can also be used with methods to return integer type values. It can hold a 32-bit signed two's complement integer. Points to remember
Examples of Java byte keywordExample 1Let's see an example to use int data type with positive and negative value. Output: num1: 10 num2: -10 Example 2Let's see an example to check whether the int data type holds decimal value. Output: error: incompatible types: possible lossy conversion from double to int Example 3Let's see an example to check whether the int data type holds float value. Output: error: incompatible types: possible lossy conversion from float to int Example 4Let's see an example to check whether the int data type holds char value.In such case, the compiler typecast the character implicitly into int type and returns the corresponding ASCII value. Output: num: 97 Example 5In this example, int data type holds the minimum and maximum value. Output: min: -2147483648 max: 2147483647 Example 6Let's create a method that returns an integer value. Output: 10 Next TopicNew-keyword-in-java |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India