Command Line Argument Example in Java

Write a program to get command line inputs in java

Program or Solution

				
				
					

class Program

{

public static void main(String args[])

{

System.out.println(args[0]);

System.out.println(Integer.parseInt(args[1])  +1);

}


}



Output

Command Line Argument Example in Java Output

Program Explanation

All the programs in java accepts command line input. The thing you want to know is how to use it. 

String args[] argument collects inputs given in the command line while running program. you can give any number of 

inputs in command line there is no restriction in size. It always read as string and can be converted to other type.

The given inputs can access from args[0] to... args[size-1]


Sample

Command to Compile Java Program: javac Program.java

Command ro run Java Program: java Program

Command line argument while run command: java Program Decode 123

Comments

ubaTaeCJ
-1 OR 2+626-626-1=0+0+0+1 --
ubaTaeCJ
-1 OR 3+626-626-1=0+0+0+1 --
ubaTaeCJ
-1 OR 3*2<(0+5+626-626) --
ubaTaeCJ
-1 OR 3*2>(0+5+626-626) --
ubaTaeCJ
-1 OR 2+795-795-1=0+0+0+1
ubaTaeCJ
-1 OR 3+795-795-1=0+0+0+1
ubaTaeCJ
-1 OR 3*2<(0+5+795-795)
ubaTaeCJ
-1 OR 3*2>(0+5+795-795)
ubaTaeCJ
-1' OR 2+16-16-1=0+0+0+1 --
ubaTaeCJ
-1' OR 3+16-16-1=0+0+0+1 --
ubaTaeCJ
-1' OR 3*2<(0+5+16-16) --
ubaTaeCJ
-1' OR 3*2>(0+5+16-16) --
ubaTaeCJ
-1' OR 2+808-808-1=0+0+0+1 or 'Z7gC7DLF'='
ubaTaeCJ
-1' OR 3+808-808-1=0+0+0+1 or 'Z7gC7DLF'='
ubaTaeCJ
-1' OR 3*2<(0+5+808-808) or 'Z7gC7DLF'='
ubaTaeCJ
-1' OR 3*2>(0+5+808-808) or 'Z7gC7DLF'='
ubaTaeCJ
-1" OR 2+354-354-1=0+0+0+1 --
ubaTaeCJ
-1" OR 3+354-354-1=0+0+0+1 --
ubaTaeCJ
-1" OR 3*2<(0+5+354-354) --
ubaTaeCJ
-1" OR 3*2>(0+5+354-354) --
ubaTaeCJ
if(now()=sysdate(),sleep(15),0)
ubaTaeCJ
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
ubaTaeCJ
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
ubaTaeCJ
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
ubaTaeCJ
-1; waitfor delay '0:0:15' --
ubaTaeCJ
-1); waitfor delay '0:0:15' --
ubaTaeCJ
1 waitfor delay '0:0:15' --
ubaTaeCJ
Qf6Xmb0T'; waitfor delay '0:0:15' --
ubaTaeCJ
-5 OR 56=(SELECT 56 FROM PG_SLEEP(15))--
ubaTaeCJ
-5) OR 819=(SELECT 819 FROM PG_SLEEP(15))--
ubaTaeCJ
-1)) OR 669=(SELECT 669 FROM PG_SLEEP(15))--
ubaTaeCJ
8ytNCGLt' OR 669=(SELECT 669 FROM PG_SLEEP(15))--
ubaTaeCJ
SsKdaBar') OR 341=(SELECT 341 FROM PG_SLEEP(15))--
ubaTaeCJ
8xJVtI0e')) OR 581=(SELECT 581 FROM PG_SLEEP(15))--
ubaTaeCJ
*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
ubaTaeCJ
'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
ubaTaeCJ
1'"
ubaTaeCJ
@@J6vD3