In this tutorial, we will discuss the int keyword in java programming language
In Java programming language, “int” is the keyword used to store the integer value. int allows the creation of methods with the return value. It is a primitive data type in Java programming languages.
It holds 32 bit signed integer value.
integer data type is able to store both unsigned and signed integer.
Syntax
the syntax of keyword an int
int <variable_name> <integer_value>;
Example of keyword an int
int number = 39; int octalNaumber=0377; int hexNumber=0xff;
public class intEx1{ public static void main (String args[]){ int age=20; System.out.println("My age is :"+age); } }
When the above code is executed, it produces the following result
My age is: 20
int add(){ //statements }
Above method is an int method with return any value.
Example int method within class
public class Example _int{ // this is a class in java public static void main(String args[]){ // this is the main method in java } public int add(){ // this is a int method with a return value; } }
Program 2
public class intEx2{ public static void main (String args[]){ my_age(20); } static int my_age(int age){ System.out.println("My age is :"+age); return; } }
When the above code is executed, it produces the following result
My age is :20
There are other Java language keywords that are similar to this keyword
Suggested for you
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…