Keyword in Java

The int keyword in Java programming language

The int keyword in Java programming language

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.

 

Declaration

Syntax

the syntax of keyword an int

int <variable_name> <integer_value>;

Example – int variable

Example of keyword an int

int number = 39;
int octalNaumber=0377;
int hexNumber=0xff;


Program 1

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

 

Example – int method

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

 byte  in Java Language

 int  in Java Language

long  in Java Language

 float  in Java Language

char  in Java Language

 void  in Java Language

try  in Java Language

Catch in Java Language

implements  in java Language

public  in Java Language

static  in Java language

Volatile  in Java Language

Package  in Java Language

class  in Java Language

boolean  in Java Language

break in Java Language

do  in Java Language

double  in Java Language

This  in Java Language

final  in Java Language

switch  in Java Language

interface  in Java Language

extends  in Java language

 

Suggested for you

 Java language Keywords

C language Keywords

 Python language Keywords

keywords in C language

Finally  in Java language

 

 

 

The void keyword in Java programming language
The short keyword in Java programming language
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago