Java Program to Print an Integer

Write a Java program to print an Integer as the output. In this example, we declared a number variable of integer type and assigned 55 to it. Next, we used the System.out.printf statement to print that integer as an output.

package SimpleNumberPrograms;

public class PrintInteger {

	public static void main(String[] args) {
		int number = 55;
		System.out.printf("\nThe integer values = %d", number );
	}
}

The integer values = 55

This Java program allows the user to enter any integer value and prints that numeric value as an output.

package SimpleNumberPrograms;

import java.util.Scanner;

public class PrintInteger2 {
	private static Scanner sc;

	public static void main(String[] args) {
		int number;
		sc = new Scanner(System.in);
		
		System.out.print("Please Enter the integer Value = ");
		number = sc.nextInt();

		System.out.println("\nThe integer value you have entered = " + number);
	}
}
Java Program to Print an Integer 1