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的
希望好心人能帮助我一下




话题树型展开
人气 标题 作者 字数 发贴时间
4846 新手问个一直不太明白的问题 rainytooo 1254 2006-04-14 14:09
3903 Re:新手问个一直不太明白的问题 rainytooo 23 2006-04-14 15:20
4263 Re:新手问个一直不太明白的问题 我所爱 32 2006-04-14 17:07
4062 Re:新手问个一直不太明白的问题 rainytooo 7 2006-04-15 20:06

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