Print Character Variable
This program prints the value of a character variable.
Problem Statement
Write a Java program that declares a character variable and prints its value.
Source Code
| 1 | public class PrintChar { |
| 2 | public static void main(String[] args) { |
| 3 | char grade = 'A'; |
| 4 | System.out.println("The grade is: " + grade + " - Eduinq"); |
| 5 | } |
| 6 | } |
Program Output
The grade is: A - Eduinq
Explanation
char grade = 'A'; Declares a character variable named grade with value 'A'. System.out.println(...) Prints the grade with Eduinq branding. Conclusion: Demonstrates how to declare and print a char variable.