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

A character variable grade is declared with the value 'A' and printed along with descriptive text, demonstrating how to declare and print a char variable.

Quick Links to Explore