Print Alphabet using For Loop :
public class Alphabet {
public static void main(String[] args) {
for (char ch='a';ch<='z';ch++){ // capital letter type 'A' and 'Z'
System.out.print(ch+" ");
}
}
}
Output :
Print Alphabet using While Loop :
public class Alphabet {
public static void main(String[] args) {
char a='a';
while (a<='z'){
System.out.println(a+" ");
a++;
}
}
}
Output :
public class Alphabet {
public static void main(String[] args) {
for (char ch='a';ch<='z';ch++){ // capital letter type 'A' and 'Z'
System.out.print(ch+" ");
}
}
}
Output :
Print Alphabet using While Loop :
public class Alphabet {
public static void main(String[] args) {
char a='a';
while (a<='z'){
System.out.println(a+" ");
a++;
}
}
}
Output :
Print Alphabet using Do While Loop :
public class Alphabet {
public static void main(String[] args) {
char a='a';
do{
System.out.println(a+" ");
a++;
}while (a<='z');
}
}
Output :
Note : if you want to write capital latter alphabet then type 'A' and 'Z' instead of 'a' and 'z'.
Start with your Choice
-Important Programs for Freshers
- Palindrome Number
- Prime Number
- Swapping Number
- Leap Year
- Odd and Even Number
- Fibonacci Series
- Armstrong Number
- Factorial Number
- Print Table
Sorting and Searching Programs
Learn Pattern Programs
- Alphabet pattern program in java
- Square pattern programs in java
- Diamond Star pattern programs in java
- Number Pattern Programs in java
- Diagonal pattern program in java
Click to learn Array Programs
- 4 ways to print Array in Java
- 2D Array in Java
- Anonymous Array in Java
- Single Dimensional Array in Java
- Find Second Largest Number in Array
- Delete an Element in Array in Java
- Common Element in Array in Java
- Missing Element in Array
- Insert Element in Array
- Smallest and Largest Elements in Array
- Find Odd and Even Number in Array
Click to Learn MySQL
Learn with us | HTML | CSS | Java Script | Bootstrap | JAVA | ADV
JAVA | SQL | GIT
No comments:
Post a Comment