Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 新手问个一直不太明白的问题
rainytooo





发贴: 5
积分: 0
于 2006-04-14 14:09 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我在做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.printlnLight Bulb;
}
}
}

我想知道的是关于
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的
希望好心人能帮助我一下



作者 Re:新手问个一直不太明白的问题 [Re:rainytooo]
rainytooo





发贴: 5
积分: 0
于 2006-04-14 15:20 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
谢谢
我以后多看看书
楼上好人
俺稀罕你



作者 Re:新手问个一直不太明白的问题 [Re:rainytooo]
我所爱

人啊!真累。



发贴: 24
积分: 0
于 2006-04-14 17:07 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
真对不起楼主,这是我今最郁闷的事,刚一不小心,把那贴给删了!!!


[img]http://list.mp3.baidu.com/list/images/tupic/funny_egaosucai01.jpg[/img]
********************
**** 我思故我在****
*******************

作者 Re:新手问个一直不太明白的问题 [Re:rainytooo]
rainytooo





发贴: 5
积分: 0
于 2006-04-15 20:06 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
楼上啥意思啊?



flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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