Java - Write code to convert char To Byte

Requirements

Write code to convert char To Byte

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        char c = 'a';
        System.out.println(charToByte(c));
    }/*from  w w w.  ja v  a  2 s. com*/

    public static byte charToByte(char c) {
        return (byte) "0123456789ABCDEF".indexOf(c);
    }
}