can anyone show an example program using command line arguments ,utilising the string args[] in main() | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

can anyone show an example program using command line arguments ,utilising the string args[] in main()

26th Jul 2016, 9:35 AM
Mohammed Raheez
Mohammed Raheez - avatar
4 Respostas
+ 1
Command line argument is for command line input. I use CMD. I can't help you with netbeans since I don't use it. Error you're getting is indicating that you're not putting in any argument to fill the args array. I can't answer whether or not netbeans allows you to put in command line arguments.
26th Jul 2016, 11:50 AM
James
James - avatar
0
class ArgumentTest{ public static void main(String[] args){ System.out.println(args[0]); } } javac ArgumentTest.java java ArgumentTest "hello"
26th Jul 2016, 11:05 AM
James
James - avatar
0
I am trying to run in netbeans it's showing array index out of bound error. :(
26th Jul 2016, 11:47 AM
Mohammed Raheez
Mohammed Raheez - avatar
0
anyway thnx bro for helping ..I just got the answer now after googling it... peace!
26th Jul 2016, 12:04 PM
Mohammed Raheez
Mohammed Raheez - avatar