943,636 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 503
  • Java RSS
Jun 22nd, 2009
0

how to modify the code to Creating multiple instances of a Class <<Very basic>>

Expand Post »
The code found below takes command lines arguiments and displays. I want to modify this code in anyway that it would take 2 set of command line arguiments and produces 2 outputs. (That means , Open 2 command prompts and run the code)

ex: first cmd prmpt -> java CmdLnArgmntExp abc
2nd --> java CmdLnArgmntExp def

*in brief --> how to modify the code to Creating multiple instances of Class CmdLnArgmntExp

Java Syntax (Toggle Plain Text)
  1. public class CmdLnArgmntExp {
  2.  
  3. public static void main(String[] args) {
  4. System.out.println("d");
  5. for (int i = 0; i < args.length; i++)
  6. System.out.println(args[i]);
  7. }
  8.  
  9. }
Similar Threads
Reputation Points: 1
Solved Threads: 3
Junior Poster
localp is offline Offline
190 posts
since Apr 2008
Jun 22nd, 2009
0

Re: how to modify the code to Creating multiple instances of a Class <<Very basic>>

Click to Expand / Collapse  Quote originally posted by localp ...
The code found below takes command lines arguiments and displays. I want to modify this code in anyway that it would take 2 set of command line arguiments and produces 2 outputs. (That means , Open 2 command prompts and run the code)

ex: first cmd prmpt -> java CmdLnArgmntExp abc
2nd --> java CmdLnArgmntExp def

*in brief --> how to modify the code to Creating multiple instances of Class CmdLnArgmntExp

Java Syntax (Toggle Plain Text)
  1. public class CmdLnArgmntExp {
  2.  
  3. public static void main(String[] args) {
  4. System.out.println("d");
  5. for (int i = 0; i < args.length; i++)
  6. System.out.println(args[i]);
  7. }
  8.  
  9. }

Right now you don't have ANY instances of CmdLnArgmntExp, much less multiple instances. Everything is in main and you have no constructor.

By "open 2 command prompts", do you mean you want two separate console windows? And who/what is opening them? You, a human being, or the program?
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,372 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Help me!!!!
Next Thread in Java Forum Timeline: Why??





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC