command line arguments

command line arguments

View Answers

March 30, 2009 at 12:05 PM

hi friend,

We are providing you a code that will prompt the user to input some numbers at the command prompt and then calculate the max and min numbers from them.

import java.util.*;

public class MaxMin {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int maxNumber = Integer.MIN_VALUE;
int minNumber = Integer.MAX_VALUE;
System.out.println("Enter numbers. Terminate with EOF.");
while (input.hasNextInt()) {
int number = input.nextInt();
if (number > maxNumber) {
maxNumber = number;
}
if (number < minNumber) {
minNumber = number;
}
}
System.out.println("Maximum Number = " + maxNumber);
System.out.println("Minimum Number= " + minNumber);
}

}

Thanks

November 26, 2010 at 1:31 AM

/* * compile this program using javac commandline.java * to run " java commandline" and check the output * use "java commandline hello "and check the ouput */

public class commandline{ public static void main(String args[]) { if(args.length>0)//check for presence of command line arguments { System.out.println("The First Command-line-arugement is "+args[0]); //Not:First command will be stored in args[0],second will be in args[1] and so on.. } else { System.out.println("No Command-line-arugement"); } } }









Related Tutorials/Questions & Answers:
Command line arguments
Command line arguments  Please explain me what is the use of "command line arguments" and why we need to use
COMMAND LINE ARGUMENTS
COMMAND LINE ARGUMENTS  JAVA PROGRAM TO ACCEPT 5 COMMAND LINE ARGUMENTS AND FIND THE SUM OF THAT FIVE.ALSO FIND OUT LARGEST AMONG THAT 5   Hi Friend, Try the following code: import java.util.*; class
Advertisements
character as command line arguments
character as command line arguments  public class testing { public static void main(String args[]) { char a; a=args[0]; System.out.println("character is:"+a); } } what will be the above program output
Command line arguments
Java application can accept any number of arguments directly from the command line. The user can enter command-line arguments when invoking the application... modifiers click on the following links Command Line Arguments
command line arguments - Java Beginners
command line arguments  how can i findout the minimum and maximum no's at the command prompt if i give some values?????????  hi friend... at the command prompt and then calculate the max and min numbers from them
how to pass command line arguments in ant
how to pass command line arguments in ant  How to pass runtime values ie commandline arguments to a program written in java using ant tool
How to pass command line arguments in Java?
How to pass command line arguments in Java?  Hi, In a Java program I have to write for reading the command line arguments and use it in a programming. How to pass command line arguments in Java? Share me the sample code
Printing Command Line arguments in JRuby
Printing Command Line arguments in JRuby... we will discuss about printing command line arguments in JRuby program. We can also take arguments from the command line into our JRuby program. 
Command Line Arguments in Java Program
Command Line Arguments in Java Program   ... directly from the command line. The user can enter command-line arguments when..., suppose a program named CmndLineArguments that accept command line arguments
please tell me about command line arguments in java?
please tell me about command line arguments in java?  please tell me about command line arguments in java?   Hi Friend, The command-line... take any number of command-line arguments which may be necessary for the program
please tell me about command line arguments in java?
please tell me about command line arguments in java?  please tell me about command line arguments in java?   Hi Friend, The command-line... take any number of command-line arguments which may be necessary for the program
Java program to get the Command Line Arguments
Java program to get the Command Line Arguments... Amit Kumar ---------->> Getting command line arguments... program we can use the string array variable args for holding command line
Sum of two numbers using command line arguments in Java
Sum of two numbers using command line arguments in Java  Hi, How to pass two values as parameter from command line and the get in it Java program? The calculate the sum of two numbers using command line arguments in Java
Command Line Arguments in Java
Command Line Arguments in Java The ongoing Java application can accept any number of arguments from the command line but it is command line argument, which.... Suppose program named CmndLineArguments that accept command line arguments
Passing Command Line Arguments
Passing Command Line Arguments     ... pass values on command line argument . We are taking a sequence of character from command line at run time. Store these strings into an array
How To Read String From Command Line In Java
giving from the command line. Command line arguments are passed... of arguments can be read given as command line and the other will explain that how we...How To Read String From Command Line In Java In this section we will discuss
Command line argument in java
Command line argument in java. In this section we are going to discuss about command line argument in java. Command line argument allow a user to pass... user to pass any number of  argument to the command line. When running
Java Command Line Input
Java Command Line Input  How to get input from command line in java ?   Hi please Find the code for inputting data from the command line System.out.println("Please Input A Number"); BufferedReader br
Compiling package in command line
package using command line. For Eg: When i compile following command, c:>set...Compiling package in command line  Hi friends, i am totally new... as an internal or external command, operable program or batch file. please help me
What is command line argument in Java
for the beginners like me.   Command line arguments allow the user... of arguments from the command line. Arguments are passed as a string array...("These are the command line arguments:"); for (int i=0; i < args.length; i
Python parse arguments
Python parse arguments Example - Learn to parse command line arguments... command line arguments. The command line arguments are the data which is passed... the command line arguments. How to get Python Command Line Arguments? There are few
ModuleNotFoundError: No module named 'command-line'
ModuleNotFoundError: No module named 'command-line'  Hi, My Python... 'command-line' How to remove the ModuleNotFoundError: No module named 'command-line' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'command-line'
ModuleNotFoundError: No module named 'command-line'  Hi, My Python... 'command-line' How to remove the ModuleNotFoundError: No module named 'command-line' error? Thanks   Hi, In your python
Java Command Line Argument Example
. These inputs are given at the time of invoking application. Command line arguments... a user can provide any number of arguments. The command line argument facilitate... these command line arguments are termed as follows : args[0] = args1; args[1
Java Generic program with command line argument
Java Generic program with command line argument  Implement Generic to perform arithmetic evaluation using command line argument by using Java
ModuleNotFoundError: No module named 'command-line-blog'
ModuleNotFoundError: No module named 'command-line-blog'  Hi, My... named 'command-line-blog' How to remove the ModuleNotFoundError: No module named 'command-line-blog' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'command_line_input'
ModuleNotFoundError: No module named 'command_line_input'  Hi, My... named 'command_line_input' How to remove the ModuleNotFoundError: No module named 'command_line_input' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'command-line-parser'
ModuleNotFoundError: No module named 'command-line-parser'  Hi, My... named 'command-line-parser' How to remove the ModuleNotFoundError: No module named 'command-line-parser' error? Thanks   Hi
ModuleNotFoundError: No module named 'command-line-parser'
ModuleNotFoundError: No module named 'command-line-parser'  Hi, My... named 'command-line-parser' How to remove the ModuleNotFoundError: No module named 'command-line-parser' error? Thanks   Hi
ModuleNotFoundError: No module named 'Tweet-Command-Line-Tool'
ModuleNotFoundError: No module named 'Tweet-Command-Line-Tool'  Hi...: No module named 'Tweet-Command-Line-Tool' How to remove the ModuleNotFoundError: No module named 'Tweet-Command-Line-Tool' error? Thanks   
ModuleNotFoundError: No module named 'censys-command-line'
ModuleNotFoundError: No module named 'censys-command-line'  Hi, My... named 'censys-command-line' How to remove the ModuleNotFoundError: No module named 'censys-command-line' error? Thanks   Hi
ModuleNotFoundError: No module named 'command-line-blog'
ModuleNotFoundError: No module named 'command-line-blog'  Hi, My... named 'command-line-blog' How to remove the ModuleNotFoundError: No module named 'command-line-blog' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'command_line_input'
ModuleNotFoundError: No module named 'command_line_input'  Hi, My... named 'command_line_input' How to remove the ModuleNotFoundError: No module named 'command_line_input' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'command-line-parser'
ModuleNotFoundError: No module named 'command-line-parser'  Hi, My... named 'command-line-parser' How to remove the ModuleNotFoundError: No module named 'command-line-parser' error? Thanks   Hi
ModuleNotFoundError: No module named 'command-line-timer'
ModuleNotFoundError: No module named 'command-line-timer'  Hi, My... named 'command-line-timer' How to remove the ModuleNotFoundError: No module named 'command-line-timer' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'confluence-command-line'
ModuleNotFoundError: No module named 'confluence-command-line'  Hi...: No module named 'confluence-command-line' How to remove the ModuleNotFoundError: No module named 'confluence-command-line' error? Thanks   
execute a PHP script using command line
script using command line?   Hi friends, Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line... interface, it may not execute properly in command line environment. Thanks
Repairing mysql database from command line
Repairing mysql database from command line  Hi, Can anyone tell me the process for repairing mysql database from command line? Thanks
How to run PHP Script from the command line ?
How to run PHP Script from the command line ?  Running PHP Script from the command line   Actually it is very simple to run php script command line. Except there are a few things that are different, for example
Java memory options from command line
Java memory options from command line  Hi, How to use java memory options from command line? Thanks   Hi, Here is the example code: java -Xms1056m -Xmx1056m MyProgram Thanks
check CentOS version via command line
check CentOS version via command line  Hi, How to see the version of centos installed from command line? Thanks   Hi, You can check it with following cat command: cat /etc/*elease Thanks
check CentOS version via command line
check CentOS version via command line  Hi, How to see the version of centos installed from command line? Thanks   Hi, You can check it with following cat command: cat /etc/*elease Thanks
Command Line Standard Output In Java
Command Line Standard Output In Java In this section we will discuss about the Command Line Java IO Standard Output. Standard streams, feature of various O/S, are written through standard output in Java. Standard streams can
How to check CentOS version via command line?
How to check CentOS version via command line?  Hi, I have a linux... system installed on it. How to check CentOS version via command line? Thanks.... You can find the CentOS version installed with the help of following command: cat
Command Line Standard Error In Java
Command Line Standard Error In Java In this section we will discuss about the Command Line Java IO Standard Error. System.out and System.err both are for Standard output but, System.err separates the error output. System.err
How to invoke method of a library from command line
How to invoke method of a library from command line  Suppose there are two methods in a libray and you have to invoke one of the method from that library directly from the command prompt. How will you do
Help on mySQL 5 command line - SQL
Help on mySQL 5 command line  Dear Sir, I had created a table... | +----+------+-------------------------? I want to use the command SELECT WORD, MIN(num_of_searches... | +------+----------------------+ What command for MIN should i used
help on mySQL 5 command Line - SQL
help on mySQL 5 command Line  Dear Sir, Sorry for my mistake... | +----+------+-------------------------?Ebr /> I want to use the command SELECT WORD, MIN(num... | +------+----------------------+ What command for MIN should i used? Thanks in advanced
Java I/O From the Command Line
Java I/O From the Command Line In this section we will learn about the I/O from the command line in Java. Several times you can see that the programs runs after taking the input from the command line. Java also supports for the command
Command Line Standard Input In Java
Command Line Standard Input In Java In this section we will discuss about the Java IO Standard Input through Command Line. Standard streams, feature... the command line interpreter. Java provides System.in to access the Standard Input

Ads