Posts

Showing posts from December 3, 2009

How to get values from command line in java

Hi friends A Java application can accept any number of arguments from the command line. This allows the user to specify configuration information when the application is launched. The user enters command-line arguments when invoking the application and specifies them after the name of the class to be run. When an application is launched, the runtime system passes the command-line arguments to the application's main method via an array of   String s.   This example is for all type data types, because from command line all the arguments are of string type. class getcommandtext {     public static void main(String[] args)     {         for (String s: args)             {             System.out.println(s);             }     } } For Numeric Command line Argument:- If an application needs to support a numeric command-line argument, it must convert a   String   argument that represents a number, such as "12", to a numeric value. class numericargument {     p