List of usage examples for java.lang Character Character
@Deprecated(since = "9") public Character(char value)
From source file:Main.java
public static void main(String[] args) throws Exception { int i = 64;/* ww w .j a v a 2 s. co m*/ String aChar = new Character((char) i).toString(); }
From source file:Main.java
public static void main(String[] args) { // Using the constructor Character c1 = new Character('A'); // Using the factory method - preferred Character c2 = Character.valueOf('2'); Character c3 = Character.valueOf('-'); // Getting the wrapped char values char cc1 = c1.charValue(); char cc2 = c2.charValue(); char cc3 = c3.charValue(); System.out.println("c1 = " + c1); System.out.println("c2 = " + c2); System.out.println("c3 = " + c3); // Using some Character class methods on c1 System.out.println("isLowerCase c1 = " + Character.isLowerCase(cc1)); System.out.println("isDigit c1 = " + Character.isDigit(cc1)); System.out.println("isLetter c1 = " + Character.isLetter(cc1)); System.out.println("Lowercase of c1 = " + Character.toLowerCase(cc1)); // Using some Character class methods on c2 System.out.println("isLowerCase c2 = " + Character.isLowerCase(cc2)); System.out.println("isDigit c2 = " + Character.isDigit(cc2)); System.out.println("isLetter c2 = " + Character.isLetter(cc2)); System.out.println("Lowercase of c2 = " + Character.toLowerCase(cc2)); System.out.println("Uppercase of c3 = " + Character.toUpperCase(cc3)); }
From source file:MainClass.java
public static void main(String args[]) { Boolean bool = Boolean.valueOf("true"); Character c = new Character('c'); Byte b = Byte.valueOf("12"); Short s = Short.valueOf("2"); Integer i = Integer.valueOf("13245"); Long l = Long.valueOf("12341234"); Float f = Float.valueOf("11234.1234"); Double d = Double.valueOf("43213241234.123412341234"); System.out.println(bool);/*w w w .ja v a 2s .c om*/ System.out.println(c); System.out.println(b); System.out.println(s); System.out.println(i); System.out.println(l); System.out.println(f); System.out.println(d); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Boolean refBoolean = new Boolean(true); boolean bool = refBoolean.booleanValue(); Byte refByte = new Byte((byte) 123); byte b = refByte.byteValue(); Character refChar = new Character('x'); char c = refChar.charValue(); Short refShort = new Short((short) 123); short s = refShort.shortValue(); Integer refInt = new Integer(123); int i = refInt.intValue(); Long refLong = new Long(123L); long l = refLong.longValue(); Float refFloat = new Float(12.3F); float f = refFloat.floatValue(); Double refDouble = new Double(12.3D); double d = refDouble.doubleValue(); }
From source file:Main.java
public static void main(String[] argv) { JTextField component = new JTextField(10); component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "none"); JFrame f = new JFrame(); f.add(component);/*from w w w.j ava2 s . c om*/ f.setSize(300, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { JTextField component = new JTextField(10); component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "actionName"); JFrame f = new JFrame(); f.add(component);/*from www . ja va2 s.c o m*/ f.setSize(300, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextField component = new JTextField(10); // Override letter a component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("typed a"), "actionName"); component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "actionName"); component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("typed X"), "none"); component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("shift pressed SPACE"), "actionName"); component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "none"); MyAction action = new MyAction(); component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("pressed SPACE"), action.getValue(Action.NAME)); component.getActionMap().put(action.getValue(Action.NAME), action); }
From source file:InsertAction.java
public static void main(String[] argv) { JTextField component = new JTextField(10); InsertAction insertSpaceAction = new InsertAction(); component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "none"); component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("pressed SPACE"), insertSpaceAction.getValue(Action.NAME)); component.getActionMap().put(insertSpaceAction.getValue(Action.NAME), insertSpaceAction); JFrame f = new JFrame(); f.add(component);/*from w w w . j a v a 2s . c o m*/ f.setSize(300, 300); f.setVisible(true); }
From source file:InsertAction.java
public static void main(String[] argv) { JTextField component = new JTextField(10); InsertAction insertSpaceAction = new InsertAction(); component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "none"); component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("pressed SPACE"), insertSpaceAction.getValue(Action.NAME)); component.getActionMap().put(insertSpaceAction.getValue(Action.NAME), insertSpaceAction); JFrame f = new JFrame(); f.add(component);/* ww w . j av a 2 s .c om*/ f.setSize(300, 300); f.setVisible(true); }
From source file:CharacterDemo.java
public static void main(String args[]) { Character a = new Character('a'); Character a2 = new Character('a'); Character b = new Character('b'); int difference = a.compareTo(b); if (difference == 0) { System.out.println("a is equal to b."); } else if (difference < 0) { System.out.println("a is less than b."); } else if (difference > 0) { System.out.println("a is greater than b."); }/*from w ww . java 2s.com*/ System.out.println("a is " + ((a.equals(a2)) ? "equal" : "not equal") + " to a2."); System.out.println("The character " + a.toString() + " is " + (Character.isUpperCase(a.charValue()) ? "upper" : "lower") + "case."); }