📌  相关文章
📜  在java代码示例中将字符串转换为int

📅  最后修改于: 2022-03-11 14:52:37.789000             🧑  作者: Mango

代码示例6
class scalerAcademy {
    public static void main ( String args [] ) {
        String str = "789"; // creating a string
        Integer ans = Integer.valueOf(str); // passing the value to an Integer class
        Integer ans1 = Integer.valueOf(str,16); // passing radix value as int
       
        System.out.println(ans); //outputs 789
        System.out.println(ans1); // outputs 1929
    }
}