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

Thread: Arrays , command line arguments

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

    Default Arrays , command line arguments

    Good evening everyone,
    i want to make a program that read a list of integers as an array then prints the reverse of it however these integers should be passed as command line arguments but my program won't compile can somebody tell me what to do
    import java.util.Arrays;
     
    public class Reverse {
    	public static void main(String[] args) {
    		for (int i = 0; i <= args.length - 1; i++) {
    			int[] numbers = Integer.parseInt(args[i]);
    			reverseInPlace(numbers);
    		}
    	}
     
    	public static void reverseInPlace(int[] a) {
     
    		for (int i = 0; i <= (a.length - 1) / 2; i++) {
    			int temp = a[i];
    			a[i] = a[a.length - 1 - i];
    			a[a.length - 1 - i] = temp;
     
    		}
    		System.out.println(Arrays.toString(a));
    	}
    }


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

    Default Re: Arrays , command line arguments

    "Won't compile" should include compiler errors. Please post any errors you are getting and want help with.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Arrays , command line arguments

    What happened to the problem in this post?
    http://www.javaprogrammingforums.com...em-arrays.html
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Help understanding Command-Line Arguments
    By Truck35 in forum Collections and Generics
    Replies: 1
    Last Post: December 13th, 2012, 06:16 PM
  2. command line arguments
    By rizla in forum Member Introductions
    Replies: 3
    Last Post: December 12th, 2010, 11:14 PM
  3. Multi-Valued Command Line Arguments
    By joey86 in forum Java Theory & Questions
    Replies: 1
    Last Post: December 29th, 2009, 11:19 AM
  4. How to Send command line arguments in Eclipse?
    By JavaPF in forum Java JDK & IDE Tutorials
    Replies: 0
    Last Post: April 23rd, 2009, 11:37 AM
  5. How to Send command line arguments in Eclipse?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: April 23rd, 2009, 11:37 AM