Deal with the Console Parameters

From Java Example Source Code

Jump to: navigation, search

Contents

[edit] Overview - Deal with the Console Parameters

This Java program shows how to deal with the console parameters.

[edit] Java Source Code

  • Package: example.console
  • File: ConsoleArguments.java
package example.console;
 
public class ConsoleArguments {
    public static void main(String[] args) {
	if (args.length == 0) {
	    System.out.println("No arguments");
	} else {
	    System.out.println("Arguments:");
	    for (int i = 0; i < args.length; i++) {
		System.out.println(args[i]);
	    }
	}
    }
}

[edit] What Result You Can Get

Run the program, you will get:


No arguments

[edit] Required External Libraries and/or Files for this Java Example

Need nothing.


[edit] How to Run this Java Example Program

We recommend running this Java example program with Eclipse.

For assistance in working with Eclipse, please see How to Run Java Program with Eclipse.

It's fairly easy.



[edit] Question & Answer

Any question?

Click edit and post your question or answer here.


Personal tools