How do i create a java program that prints "I Love Programming Languages" when nothing is passed to it and if some string is passed then the string is printed?
Answers
Explanation:
public class CmdLineArg
{
public static void main(String[] args) {
if (args.length == 0 )
System.out.println("I Love Programming Languages");
else
System.out.println("Your first argument is: "+args[0]);
}
}
command line arguments should be passed while running the program through command line. Its easy to do this in command line than through any other IDE.
args.length allows us to find whether any command line arguments are passed. If passed we are printing the first argument alone. If you want, you can enhance the program by printing all the arguments using loop.
To Know More:
https://brainly.in/question/2993590
Practice programs on command line arguments in java
https://brainly.in/question/5081158
Write a program that accepts two strings as command line arguments and generate the output in a specific way as given below. example: if the two command line arguments are wipro and bangalore then the output generated should be wipro technologies bangalore. if the command line arguments are abc and mumbai then the output generated should be abc technologies mumbai [note: it is mandatory to pass two arguments in command line]