parse value to char - Android java.lang

Android examples for java.lang:String Parse

Description

parse value to char

Demo Code


//package com.java2s;
import android.text.TextUtils;

public class Main {
    /**//from   ww  w.jav  a2  s .c  o  m
     * parse value to char
     */
    public static char toChar(Object value) {
        if (value instanceof Character) {
            return (Character) value;
        }
        return value == null ? '\0' : toChar(String.valueOf(value));
    }

    /**
     * parse value to char
     */
    public static char toChar(String value) {
        return TextUtils.isEmpty(value) ? '\0' : value.charAt(0);
    }
}

Related Tutorials