I pass the command line argument using Netbeans, but I get ArrayIndexOutOfBoundsException.
ArrayIndexOutOfBoundsException
My code is:
public class CmdLineArgumentPassing { public static void main(String args[]) { System.out.println("Count : " + args.length); System.out.println("i : "+args[0]); } }
Conclusion:
Count : 0 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
Right-click on the project, select Properties, go to the Run page, add command line arguments.
Since your result Count : 0, then the array argshas lengthof 0, which means that no arguments are passed.
Count : 0
args
length
0
arg[0], , , . . , 0 length - 1.
arg[0]
length - 1
args , , , Netbeans , , Netbeans .
, /run/arguments, ( → run), , , . , , "". , .
Click "Final proj" and run, and not the main project for netbeans 6.9. U will get an answer.
Source: https://habr.com/ru/post/1759470/More articles:Factory Girl created objects that do not clean between tests? - ruby-on-railsCheck if textarea has any characters (and ignore spaces) before sending - jqueryhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1759467/can-i-open-multiple-connections-to-a-http-server&usg=ALkJrhgO660kDbeyVsqUXivjORsCJUEpQwДолжен ли я установить Imagmagick над gd - phpCalculating the number of months between dates - phpC # WebClient Using Async and returning data - c #postgresql full-text search query for django ORM - djangoHibernate, Persistence and @OneToMany and @ManyToOne annotation problems - javaGdb does not give a stack with a simple exception std :: string - c ++Callback without function pointer - cAll Articles