java print integer code example

Example 1: java print out int and string

public class Test 
{ 
    public static void main(String[] args) 
    { 
        System.out.println(45+5 + "=" +45+5); 
    } 
}

Example 2: how to output given number java

import java.util.Scanner;

public class HelloWorld {

    public static void main(String[] args) {

        // Creates a reader instance which takes
        // input from standard input - keyboard
        Scanner reader = new Scanner(System.in);
        System.out.print("Enter a number: ");

        // nextInt() reads the next integer from the keyboard
        int number = reader.nextInt();

        // println() prints the following line to the output screen
        System.out.println("You entered: " + number);
    }
}

Example 3: print an integer in java

public class HelloWorld {
    public static void main(String[] args) {
        int number = 45;
        System.out.println("You entered: " + number);
        // output => You entered: 45
    }
}

Tags:

Java Example