衫裤跑路 2011-04-07 10:27 采纳率: 50%
浏览 394
已采纳

如何在 Java 中将一个字符串转换为一个 int 类型?

How can I convert a String to an int in Java?

My String contains only numbers, and I want to return the number it represents.

For example, given the string "1234" the result should be the number 1234.

转载于:https://stackoverflow.com/questions/5585779/how-do-i-convert-a-string-to-an-int-in-java

  • 写回答

30条回答 默认 最新

  • 7*4 2011-04-07 10:29
    关注
    String myString = "1234";
    int foo = Integer.parseInt(myString);
    

    See the Java Documentation for more information.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(29条)
编辑
预览

报告相同问题?