449.字符转整数

449. Char to Integer

Description

Convert a char to an integer. You can assume the char is in ASCII code (See Definition, so the value of the char should be in 0~255.

Example

Given a, return 97.

Given %, return 37.

public class Solution {
    /**
     * @param character: a character
     * @return: An integer
     */
    public int charToInteger(char character) {
        return character+0;
        //字符加0 变为INt
        // int加""  变为String
    }
}

描述
将字符转换为一个整数。你可以假设字符是ASCII码,也就是说转换后的整数在0~255之间。

您在真实的面试中是否遇到过这个题?  
样例
给出 a, 返回 97。
给出 %, 返回 37。
posted @ 2019-04-02 22:46  故人叹  阅读(202)  评论(0)    收藏  举报