/* primitive data types are "primitive" because they are not created from classes Java provides wrapper classes for all the primitive data types Wrapper class "wrapped around" a primitive data type and allows creation of objects, instead of variables Benefit? provide methods that perform useful operations on primitive values "Character" class = wrapper class, java.lang package, no import necessary provides several static methods */ import javax.swing.JOptionPane; public class eg19_CharacterTest { public static void main (String[] args) { String input; //hold user input char ch; //hold single char input = JOptionPane.showInputDialog("Enter any single character."); ch = input.charAt(0); if (Character.isLetter(ch)) { JOptionPane.showMessageDialog(null, "This is a letter."); } if (Character.isDigit(ch)) { JOptionPane.showMessageDialog(null, "This is a digit."); } if (Character.isLowerCase(ch)) { JOptionPane.showMessageDialog(null, "This is a lowercase letter."); } if (Character.isUpperCase(ch)) { JOptionPane.showMessageDialog(null, "This is a uppercase letter."); } if (Character.isSpaceChar(ch)) { JOptionPane.showMessageDialog(null, "This is a space."); } if (Character.isWhitespace(ch)) //space, tab or newline, cannot test tab or newline in this setting { JOptionPane.showMessageDialog(null, "This is a whitespace char."); } } }