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 8 of 8

Thread: Please help wih JAVA!!

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please help wih JAVA!!

    I have a question from class and need to write a simple main program that would print out any command line arguments in reverse.
    Im still quite new to Java as this is my first course.

    An example of what the program would do was given:

    example. javac Test.java
    java Test one two three
    three two one

    java Test 4 1 Hello
    Hello 1 4


    Thank you to anyone who can help me, life saver!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Please help wih JAVA!!

    What have you tried? Post the code you are working on ask ask some specific questions about the problems you are having. Be sure to wrap the code in code tags.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Please help wih JAVA!!

    Most beginning Java courses don't introduce Arrays until mid to late in the course, if at all. This assignment requires some moderate to advanced understanding of Arrays, so it's either a poorly timed assignment, or you should be able to write enough code to get this program started. Either way, start here, try to start the program, then post the results with specific questions, errors you want help with, etc.

  4. #4
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please help wih JAVA!!

    Quote Originally Posted by GregBrannon View Post
    Most beginning Java courses don't introduce Arrays until mid to late in the course, if at all. This assignment requires some moderate to advanced understanding of Arrays, so it's either a poorly timed assignment, or you should be able to write enough code to get this program started. Either way, start here, try to start the program, then post the results with specific questions, errors you want help with, etc.
    Yea its the first semester and I am totally lost, all i have is this:
    code to show how to go reverse in an array but im not sure what to do for command line arg.

    int[]a = new int[2]
    a[0] = 2;
    a[1] = 3;
    a[2] = 5;

    for(int i =a.length-1; i >=0; i --)
    System.out.println(a[i]);


    Im not sure what to do at all, i was hoping i could recieve some help.

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

    Default Re: Please help wih JAVA!!

    What is the int array for? Do you understand what they mean by command line arguments?

    java Test one two three

    The Strings one two and three will be inserted into a String array and passed into your main method as a parameter. To the args parameter to be exact. So you need to write a loop that will iterate over the args array and print out all the elements.
    Improving the world one idiot at a time!

  6. #6
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please help wih JAVA!!

    Its a midterm question that i didnt know, all it said was "write a main program that would print out any command line arguments in reverse"

    Im not too sure how to set up the main program, i understand that it will call on the procedure, Im just not sure how to set it up.

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

    Default Re: Please help wih JAVA!!

    The loop in the code posted above is on the right track you just need to use the args array and not some other array you created.
    Improving the world one idiot at a time!

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Please help wih JAVA!!

    Start by making a copy of the small program at the "here" link in post#3. Copy and execute that to see what happens. Then make some changes to the code to experiment.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Generate Barcode wih XZing
    By olgunk in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 2nd, 2013, 02:04 AM
  2. Help wih implementation...
    By Frank_nor in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 24th, 2009, 05:43 PM