• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Command line input  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi
Can we use command line arguments output as input to manuplicate in another set of task?
eg:
class CommandLine
{
public static void main(String args[])
{
for (int i=0;i<args.length;i++)>
System.out.println(args[i]);
}
}
when i execute this
java CommandLine 1234
output is
1234
now i want to use this output as an input to do manuplations is it possible, if so pl explain?
regards
k7
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

the command line arguements can be used as the input from the console but the point u have to remember is that the they are strings.
they have to be modified as usable form before they are used
class CommandLine
{
public static void main(String args[])
{

String s=args[0];
int i=Integer.parseInt(s);
i=i/2;
System.out.println("half of what u entered\t=\t"+i);
}
}
this requires knowledge of wraper classes.
thank u
balakrishna
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!