COMMAND LINE ARGUMENT IN JAVA:
Command line argument allows the user to enter large number of argument when running the application command line argument is entered after the name of class to be run as you can see in the below program that command line argument is entered after biob (class name).
CODING:
class biob{
public static void main(String args[])
{
String str = args[0];
int a=Integer.parseInt(args[1]);
float fl=Float.parseFloat(args[2]);
double doub=Double.parseDouble(args[3]);
short sho=Short.parseShort(args[4]);
byte by=Byte.parseByte(args[5]);
long lo=Long.parseLong(args[6]);
System.out.println("Strnig:"+str);
System.out.println("Int Data:"+a);
System.out.println("Double Number:"+doub);
System.out.println("Short Number:"+sho);
System.out.println("Byte Number:"+by);
System.out.println("Long Number:"+lo);
System.out.println("Float Number:"+fl);
}
}
No comments:
Post a Comment