Topic: 新手问个一直不太明白的问题 |
Print this page |
1.新手问个一直不太明白的问题 | Copy to clipboard |
Posted by: rainytooo Posted on: 2006-04-14 14:09 我在做thinking in java 里的题的时候 有这个题 //以两个嵌套的(nested) for 循环 和模数运算符(%)来侦测质数,并打印 import java.util.*; public class MyTest{ public static void main(String[] args){ int max = 100; //get the max value form the command line, //if the argument has been provided: if (args.length != 0) max = Integer.parseInt(args[0]); for (int i = 1; i < max; i++){ boolean prime = true; for (int j = 2; j < i; j++) if(i % j == 0) prime = false; if (prime) System.out.println; } } } 我想知道的是关于 if (args.length != 0) max = Integer.parseInt(args[0]); 这两句中的Integer.parseInt(args[0])是什么用法? API里只看到了 parseInt("0", 10) returns 0 parseInt("473", 10) returns 473 parseInt("-0", 10) returns 0 parseInt("-FF", 16) returns -255 parseInt("1100110", 2) returns 102 parseInt("2147483647", 10) returns 2147483647 parseInt("-2147483648", 10) returns -2147483648 parseInt("2147483648", 10) throws a NumberFormatException parseInt("99", 8) throws a NumberFormatException parseInt("Kona", 10) throws a NumberFormatException parseInt("Kona", 27) returns 411787 “args”究竟是什么? 为什么会有parseInt(args[0])这种用法? 还有就是 什么不用import 什么需要import 比如System就不用在前面申明import 我是新学JAVA的 希望好心人能帮助我一下 |
2.Re:新手问个一直不太明白的问题 [Re: rainytooo] | Copy to clipboard |
Posted by: rainytooo Posted on: 2006-04-14 15:20 谢谢 我以后多看看书 楼上好人 俺稀罕你 |
3.Re:新手问个一直不太明白的问题 [Re: rainytooo] | Copy to clipboard |
Posted by: 我所爱 Posted on: 2006-04-14 17:07 真对不起楼主,这是我今最郁闷的事,刚一不小心,把那贴给删了!!! |
4.Re:新手问个一直不太明白的问题 [Re: rainytooo] | Copy to clipboard |
Posted by: rainytooo Posted on: 2006-04-15 20:06 楼上啥意思啊? |
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 |