Example usage for java.lang Character charValue

List of usage examples for java.lang Character charValue

Introduction

In this page you can find the example usage for java.lang Character charValue.

Prototype

@HotSpotIntrinsicCandidate
public char charValue() 

Source Link

Document

Returns the value of this Character object.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    char c = '*';
    Character c2 = new Character(c);
    System.out.println(c2.charValue());
}

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:MainClass.java

public static void main(String[] args) {
    Character c1 = new Character('6');
    Character c2 = new Character('7');

    char c3 = c1.charValue();
    char c4 = c2.charValue();

    if (c3 < c4)
        System.out.println(c3 + " is less than " + c4);

    if (c1.compareTo(c2) < 0)
        System.out.println(c1 + " is less than " + c4);
}

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: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  w  w .j a v a  2  s.  c o m*/

    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.");
}

From source file:Main.java

/**
 * unbox Character/*from w ww .ja  va  2s .c o  m*/
 */
public static char unboxed(Character v) {
    return v == null ? '\0' : v.charValue();
}

From source file:Main.java

static List<Byte> unicode2han3last_direct(Character c) {
    Integer code = (int) c.charValue();
    if (code >= 44032 && code <= 55203) { // Korean Area
        code -= 44032;//ww  w .j  a v a  2 s . c o  m
        Integer last = code % 28;
        code = (code / 28);
        Integer middle = code % 21;
        Integer first = code / 21;
        return Arrays.asList(concatAll(first_set[first], middle_set[middle], last_set[last]));
    }
    if (code >= 12593 && code <= 12643) { // child sound
        return Arrays.asList(single_set[code - 12593]);
    }
    return Arrays.asList(code.byteValue());
}

From source file:org.apache.logging.log4j.core.layout.AbstractCsvLayout.java

private static boolean isNotNul(final Character character) {
    return character != null && character.charValue() != 0;
}

From source file:org.eclipse.jubula.rc.common.util.PropertyUtil.java

/**
 * Returns a sorted map consisting of the bean properties of a component
 * /*from w w w .  j  av  a2 s .  co  m*/
 * @param currComp 
 *              the component
 * @return the sorted map of properties
 */
public static Map getMapOfComponentProperties(final Object currComp) {
    PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(currComp);
    Map componentProperties = new TreeMap();
    for (int i = 0; i < propertyDescriptors.length; i++) {
        PropertyDescriptor pd = propertyDescriptors[i];
        try {
            Method readMethod = pd.getReadMethod();
            if (readMethod != null) {
                Object obj = readMethod.invoke(currComp, new Object[] {});
                String value = String.valueOf(obj);
                if (value.length() > 200) {
                    value = StringUtils.substring(value, 0, 200);
                }
                if (obj instanceof Character) {
                    Character c = (Character) obj;
                    if (c.charValue() == 0) {
                        value = ""; //$NON-NLS-1$
                    }
                }
                componentProperties.put(pd.getName(), value);
            } else {
                componentProperties.put(pd.getName(), "This property is not readable"); //$NON-NLS-1$
            }
        } catch (IllegalArgumentException e) {
            componentProperties.put(pd.getName(), "Error"); //$NON-NLS-1$
        } catch (IllegalAccessException e) {
            componentProperties.put(pd.getName(), "Error accessing this property"); //$NON-NLS-1$
        } catch (InvocationTargetException e) {
            componentProperties.put(pd.getName(), "Error reading this property"); //$NON-NLS-1$
        }
    }
    return componentProperties;
}

From source file:Main.java

/**
 * <p>Converts the character to a String that contains the one character.</p>
 * /*from w w  w .j av a 2 s .c  om*/
 * <p>For ASCII 7 bit characters, this uses a cache that will return the
 * same String object each time.</p>
 * 
 * <p>If {@code null} is passed in, {@code null} will be returned.</p>
 *
 * <pre>
 *   CharUtils.toString(null) = null
 *   CharUtils.toString(' ')  = " "
 *   CharUtils.toString('A')  = "A"
 * </pre>
 *
 * @param ch  the character to convert
 * @return a String containing the one specified character
 */
public static String toString(Character ch) {
    if (ch == null) {
        return null;
    }
    return toString(ch.charValue());
}