Topic: 【求助】字符串转换为数字求助 |
Print this page |
1.【求助】字符串转换为数字求助 | Copy to clipboard |
Posted by: zgia Posted on: 2005-03-15 13:08 String str1 = new String("212345672"); 我想把其中的第5位(5)取出来作为整数5,该如何操作? 另外,如何得到整数12345的长度呢? |
2.Re:【求助】字符串转换为数字求助 [Re: zgia] | Copy to clipboard |
Posted by: j0hnny Posted on: 2005-03-15 14:20 应该用subString操作吧 |
3.Re:【求助】字符串转换为数字求助 [Re: zgia] | Copy to clipboard |
Posted by: yangnian Posted on: 2005-03-15 14:33 class Str { public static void main(String[] args) { String s = "212345672"; String s1 = s.substring(5,6); int i = Integer.parseInt(s1); System.out.print("i="+i); } } |
4.Re:【求助】字符串转换为数字求助 [Re: zgia] | Copy to clipboard |
Posted by: xinye0123 Posted on: 2005-03-17 23:35 int i = Integer.parseInt(s1); 该句有可能抛出异常,注意一下 |
5.Re:【求助】字符串转换为数字求助 [Re: zgia] | Copy to clipboard |
Posted by: 寂寞高手 Posted on: 2005-03-22 13:50 看了楼主的作法,学到了东西。谢谢。 |
6.Re:【求助】字符串转换为数字求助 [Re: zgia] | Copy to clipboard |
Posted by: daniel84 Posted on: 2005-04-05 21:47 我怎么编译时有错误呀? 能否帮我写个完整的程序代码,谢谢! |
7.Re:【求助】字符串转换为数字求助 [Re: zgia] | Copy to clipboard |
Posted by: wan212 Posted on: 2005-04-05 21:57 我又学到了点东西 |
8.Re:【求助】字符串转换为数字求助 [Re: zgia] | Copy to clipboard |
Posted by: jasontaoge Posted on: 2005-04-06 10:09 class spoon { public static void main(String []args){ String str1 = new String("212345672"); char s=str1.charAt(5); System.out.println(str1.substring(5,6)); System.out.println; } } 都可以做到的! |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |