The following program demonstrates how to Arrange Two Characters in Ascending Order in Java.

In order to arrange characters in ascending order, we need the ASCII values of these characters. For this purpose, we assign these characters to integer variables. Then we can compare them using if statement.

public class Exercise4
{
	public static void main(String[] args) {
		char c1, c2;
		int n1, n2;
		c1='a';
		c2='h';
		n1=c1;
		n2=c2;
		if(n1>n2)
			System.out.println(c2+", "+c1);
		else
			System.out.println(c1+", "+c2);
	}
}

Output

A Program to Arrange Two Characters in Ascending Order in Java
A Program to Arrange Two Characters in Ascending Order in Java

Further Reading

Java Practice Exercise

programmingempire

Princites