Print Integer Variable

This program prints the value of an integer variable to the console.

Problem Statement

Write a Java program that declares an integer variable and prints its value.

Source Code

1 public class PrintInteger {
2 public static void main(String[] args) {
3 int num = 25;
4 System.out.println("The integer value is: " + num + " - Eduinq");
5 }
6 }

Program Output

The integer value is: 25 - Eduinq

Explanation

int num = 25; Declares an integer variable named num and assigns it the value 25. System.out.println("The integer value is: " + num + " - Eduinq"); Prints a message along with the value of num, followed by Eduinq branding. Closing braces } End of method and class. Conclusion: This program demonstrates how to declare an integer variable and print its value. It shows the use of concatenation to combine text with variable values.

Quick Links to Explore