-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path002-Print-Variables.java
More file actions
57 lines (45 loc) · 1.79 KB
/
Copy path002-Print-Variables.java
File metadata and controls
57 lines (45 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* ============================================================================
* Program Name : Print Variables
* File Name : 002-Print-Variables.java
* Class Name : PrintVariables
*
* Description:
* This program demonstrates how to declare, initialize, and print
* different types of variables in Java.
*
* Objective:
* - Learn how to declare variables.
* - Understand variable initialization.
* - Display variable values using System.out.println().
*
* Author : Shaik Mahaboob Basha
* Repository : 01-Core-Java
* Folder : 08-Java-Programs
* ============================================================================
*/
public class PrintVariables {
// The main() method is the entry point of every Java application.
public static void main(String[] args) {
// Declare and initialize an integer variable.
int age = 25;
// Declare and initialize a double variable.
double salary = 45000.75;
// Declare and initialize a character variable.
char grade = 'A';
// Declare and initialize a boolean variable.
boolean isJavaEasy = true;
// Declare and initialize a String variable.
String name = "Shaik Mahaboob Basha";
// Print the integer variable.
System.out.println("Age: " + age); // Output: Age: 25
// Print the double variable.
System.out.println("Salary: " + salary); // Output: Salary: 45000.75
// Print the character variable.
System.out.println("Grade: " + grade); // Output: Grade: A
// Print the boolean variable.
System.out.println("Is Java Easy: " + isJavaEasy); // Output: Is Java Easy: true
// Print the String variable.
System.out.println("Name: " + name); // Output: Name: Shaik Mahaboob Basha
}
}