Character formatting formats the values of char primitive data type or Character objects.
It can be applied to the values of byte, Byte, short, Short, int, or Integer types if their values are valid Unicode value.
You can test if an integer value represents a valid Unicode code point by using the Character.isValidCodePoint(int value).
The conversion character for character formatting is 'c'.
Its uppercase variant is 'C'.
The flag '#' and the precision are not supported for character formatting.
The flag '-' and width have the same meaning as in the context of the general formatting.
The following code demonstrates the use of character formatting:
public class Main { public static void main(String[] args) { System.out.printf("%c %n", 'a'); System.out.printf("%C %n", 'a'); System.out.printf("%C %n", 98); System.out.printf("'%5C' %n", 100); System.out.printf("'%-5C' %n", 100); }/*from ww w . j av a 2s.c o m*/ }