• Post Reply Bookmark Topic Watch Topic
  • New Topic

puzzled in args.length  RSS feed

 
rico yu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class Test{
public static void main(String[] args){
File file=new File(".");
String[] list;
if(args.length==0)//I don't understand this sentence,what's it mean?
//thank you
list=path.list();
...............
...........
}
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

That is a check whether there were any parameters passed in from the command line. Those would be in the "args" array, and "length" returns the number of elements in an array.
I would comment further on what it might do specifically in this code, but since "path" is not declared in this excerpt, it's hard to tell.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!