Java Program to Display Characters from A to Z using loop :



//Write a ‘java’ program to display characters from ‘A’ to ‘Z’.


public class Myapp


{

public static void main(String args [])

 {

char c;

for(c = 'a'; c <= 'z'; ++c)

System.out.print(c + " ");

}

Output:

Microsoft Windows [Version 10.0.18363.1440]

(c) 2019 Microsoft Corporation. All rights reserved.

C:\javaprograms>javac Practical1.java

C:\javaprograms>java Practical1

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

C:\javaprograms>




We have get public class 'Myapp' . then we mention main method with void return type. 
then we declare variable 'c' with charecter datatype, and we get for loop for displaying alphabets from A-Z.

in for loop first we initialize value as 'c=a' and condition is 'c <= z' and c++.
and simply print the value, as result. 





How To Execute Program -

firstly save program with same name of class name with java extension. 
then open cmd ( comand prompt ) in path of this program and compile the program by 'javac filename.java' comand. 
after compiled program, run the program by 'java filename' comand.