One of the textbook exercise to get start with any programming language is writing a program to print alphabets in both upper and lower case. This program allows you to explore the String class in Java with
toUpperCase() and
toLowerCase() method but normally when you start, it's asked to do this without any API methods. This kind of exercise actually improves your understanding of programming language e.g. basic operators, data types like
int and
char. It's similar to your
prime number,
Fibonacci series and factorial program exercise. I strongly suggest to do this textbook exercises to any one who is just started learning a new programming language. Coming back to this program, Java has a datatype called char, which is 2 byte unsigned integer type. It is used to store characters in Java e.g. char A = 'A'. Similar to String literal "A" we also have character literal 'A' which is letters enclosed in single quotes. There is worth-noting difference between storing character literal in
char and
int data type in Java. If you store character literal on integer variable e.g.
int i = 'a'; will store ASCII value of 'a' and when you print, it will prints ASCII value of 'a'.