Here you can find the source of valueOf(char hexChar)
Parameter | Description |
---|---|
hexChar | Hex character, such as '0' or 'A' |
public static byte valueOf(char hexChar)
//package com.java2s; /*// w ww .j a v a 2 s . c om * File: HashFunctionUtil.java * Authors: Kevin R. Dixon * Company: Sandia National Laboratories * Project: Cognitive Foundry * * Copyright Jan 26, 2011, Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the U.S. Government. * Export of this program may require a license from the United States * Government. See CopyrightHistory.txt for complete details. * */ public class Main { /** * Char table for convenience */ static final char[] HEX_CHAR_TABLE = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; /** * Returns the hex value of the given character * @param hexChar * Hex character, such as '0' or 'A' * @return * The value of the hex character. */ public static byte valueOf(char hexChar) { hexChar = Character.toLowerCase(hexChar); for (byte i = 0; i < HEX_CHAR_TABLE.length; i++) { if (hexChar == HEX_CHAR_TABLE[i]) { return i; } } throw new IllegalArgumentException(hexChar + " is not a hex char"); } }