Today, I was learning about passing arguments to the main function in JAVA , with no IDE , only on Notepad and I encountered that it can only be done using command line arguments . My question is how?
We can do this simply by opening the cmd , and writing the
javac file_name.java
java file_name [set of arguments]...
suppose the program is like
class temp
{
public static void main(String[] args)
{
System.out.println(args[0]);
System.out.println(args[1]);
//And so on
// As per the length of args
}
}
And if we pass
javac temp.java
java temp_name hello world
it will give output as
hello
world