🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
1. Introduction
In Java, characters are represented using a Unicode character set. Each character corresponds to a unique Unicode value. The characters 'A' to 'Z' have Unicode values from 65 to 90. In this blog post, we will write a Java program that uses a loop to display characters from 'A' to 'Z'.
2. Program Steps
1. Define a class named DisplayCharacters.
2. Inside the main method, use a for loop.
3. Initialize the loop variable i to 65 (Unicode value of 'A').
4. Continue the loop as long as i is less than or equal to 90 (Unicode value of 'Z').
5. In each iteration, cast i to char and print the character.
6. Increment i in each iteration.
3. Code Program
public class DisplayCharacters { // Step 1: Define a class named DisplayCharacters
public static void main(String[] args) { // Main method
// Step 3: Initialize i to 65 and Step 4: Continue as long as i is less than or equal to 90
for (int i = 65; i <= 90; i++) {
// Step 5: Cast i to char and print the character
System.out.print((char) i + " ");
}
}
}
Output:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
4. Step By Step Explanation
Step 1: The class DisplayCharacters is defined.
Steps 3 and 4: Inside the main method, a for loop is used, initializing i to 65 and continuing as long as i is less than or equal to 90.
Step 5: In each iteration of the loop, i is cast to char to convert the Unicode value to a character, which is then printed.
Step 6: The loop variable i is incremented in each iteration, moving on to the next character in the sequence from 'A' to 'Z'.
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment