What Exacly (args.length>0) means?

前端 未结 6 1354
既然无缘
既然无缘 2021-01-27 23:06

This may be simple to you people but as i am new to java, so i want know actually what is going on in the following part?

if (args.length > 0) {
    file =          


        
6条回答
  •  天命终不由人
    2021-01-27 23:35

    The args.length value is the number of items in the args array.

    If you pass no command-line arguments, you will always get "There are 0 command line arguments".

    thats why you checking

    if (args.length > 0) 
    

    But try running the program like this: java PrintArgs hello my name is mikki2 The words after java PrintArgs are called command line arguments because they are arguments passed to your program from the command line

提交回复
热议问题