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 ww w.j  a v a2 s.  com

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