Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 12 of 12

Thread: Command Line Argument - URGENT!

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Exclamation Command Line Argument - URGENT!

    Hi guys,

    this is my question that i need help in:

    Write an application that takes as a command line argument a word and outputs
    how many character are in the word.
    If called with the command line arguments Computing and Freedom would
    output:
    Computing has 9 characters
    Freedom has 7 characters


    have no idea how to do it, so please someone help!!

    Thanks!


  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Command Line Argument - URGENT!

    The following should be sufficient information on how to undertake this task.
    Scanner.
    String.

    Check out the different methods available to you, especially nextLine() from Scanner and length() from String.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  3. #3
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Command Line Argument - URGENT!

    Do not mark your posts as URGENT. Your time constraints are your problem not ours. You are not more important than anyone else seeking help. Many like me refuse to help people who scream URGENT at us, which hinders your chances of getting help not enhancing it.
    Improving the world one idiot at a time!

  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Command Line Argument - URGENT!

    Quote Originally Posted by newbie View Post
    The following should be sufficient information on how to undertake this task.
    Scanner.
    Since the requirement states using command line arguments, the Scanner class would not be needed.
    Improving the world one idiot at a time!

  5. #5
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Command Line Argument - URGENT!

    Ah indeed, must've read his post wrong
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  6. #6
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Command Line Argument - URGENT!

    Here is an example of reading a command line argument:

    public class CommandLine {
     
    	/**
    	 * JavaProgrammingForums.com
    	 */
    	public static void main(String[] args) {
     
    		System.out.println(args[0]);
    	}
     
    }

    The first argument you give when compiling the code will be printed out. You can take it from there..

    If you are using the Eclipse IDE, please see - http://www.javaprogrammingforums.com...s-eclipse.html
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  7. The Following User Says Thank You to JavaPF For This Useful Post:

    Rads23 (August 18th, 2011)

  8. #7
    Junior Member
    Join Date
    Aug 2011
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Command Line Argument - URGENT!

    Quote Originally Posted by Junky View Post
    Do not mark your posts as URGENT. Your time constraints are your problem not ours. You are not more important than anyone else seeking help. Many like me refuse to help people who scream URGENT at us, which hinders your chances of getting help not enhancing it.


    then why have an option of urgent if anyone isnt allowed to use it?

  9. #8
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Command Line Argument - URGENT!

    Quote Originally Posted by Rads23 View Post
    then why have an option of urgent if anyone isnt allowed to use it?
    What option are you talking about? You just added an annoying all-caps "URGENT" to the title. That's not an option, that's you being obnoxious. Follow that with a homework dump, and I'm surprised you got any help at all. You should be thanking them, not arguing about whether you should or should not be given the option to post annoying titles.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  10. #9
    Junior Member
    Join Date
    Aug 2011
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Command Line Argument - URGENT!

    Quote Originally Posted by KevinWorkman View Post
    What option are you talking about? You just added an annoying all-caps "URGENT" to the title. That's not an option, that's you being obnoxious. Follow that with a homework dump, and I'm surprised you got any help at all. You should be thanking them, not arguing about whether you should or should not be given the option to post annoying titles.

    As matter of a fact, i thanked the person who helped me! Dont talk if you dont know.

  11. #10
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Command Line Argument - URGENT!

    thanking them, not arguing
    Dont talk if you dont know
    Noone was talking, only writing
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  12. #11
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Command Line Argument - URGENT!

    Quote Originally Posted by Rads23 View Post
    As matter of a fact, i thanked the person who helped me! Dont talk if you dont know.
    That's fine, but then you followed up with a confrontational "why let me do this" when all that was said was that marking your threads as urgent annoys people and decreases your chances of getting help- which continuing with "debates" will certainly not fix. Best to say "okay got it", move on, and don't do it in the future.

    For more information, see the link in my signature on asking questions the smart way, especially the parts titled "Don't post homework questions", "Don't flag your question as URGENT, even if it is for you", and "Courtesy never hurts, and sometimes helps".
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  13. #12
    Junior Member
    Join Date
    Aug 2011
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Command Line Argument - URGENT!

    Quote Originally Posted by newbie View Post
    Noone was talking, only writing
    Lol, Ok sorry for any rudeness! Appreciate all the help given, thank you all! x

Similar Threads

  1. jre version in command line
    By major in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 14th, 2011, 06:55 AM
  2. Text editor and command line
    By cl2606 in forum Java IDEs
    Replies: 2
    Last Post: June 8th, 2011, 08:20 AM
  3. command line arguments
    By rizla in forum Member Introductions
    Replies: 3
    Last Post: December 12th, 2010, 11:14 PM
  4. A problem with command line compilation
    By goodguy in forum Java Theory & Questions
    Replies: 4
    Last Post: August 2nd, 2010, 10:58 AM
  5. [SOLVED] Command Line Argument Help
    By EmSaint in forum Loops & Control Statements
    Replies: 2
    Last Post: January 28th, 2010, 10:55 AM