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

Thread: Array problem i glad for help

  1. #1
    Junior Member
    Join Date
    Dec 2017
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Array problem i glad for help

    how i suppost to do it
    i want my main
    		printarr(arr);
    connect to this
    	private static void printarr(int[] arr) {
    		int[] arr = new int[5];
     
    	}
    what i need to do
    thank for help

  2. #2
    Member John Joe's Avatar
    Join Date
    Jun 2017
    Posts
    277
    My Mood
    Amused
    Thanks
    8
    Thanked 19 Times in 19 Posts

    Default Re: Array problem i glad for help

    have you declare arr in your main ?
    Whatever you are, be a good one

  3. #3
    Junior Member
    Join Date
    Dec 2017
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Array problem i glad for help

    Quote Originally Posted by John Joe View Post
    have you declare arr in your main ?
    yes how i need to declare in my main

  4. #4
    Member John Joe's Avatar
    Join Date
    Jun 2017
    Posts
    277
    My Mood
    Amused
    Thanks
    8
    Thanked 19 Times in 19 Posts

    Default Re: Array problem i glad for help

    can you post your main first before we continue ?
    Last edited by John Joe; December 4th, 2017 at 08:49 AM.
    Whatever you are, be a good one

  5. #5
    Junior Member
    Join Date
    Dec 2017
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Array problem i glad for help

    Quote Originally Posted by John Joe View Post
    can you post your main first before we continue ?
    never mind i found the problem
    can you lock in this post and thx for try

  6. #6
    Member John Joe's Avatar
    Join Date
    Jun 2017
    Posts
    277
    My Mood
    Amused
    Thanks
    8
    Thanked 19 Times in 19 Posts

    Default Re: Array problem i glad for help

    Quote Originally Posted by khjhpopasa View Post
    never mind i found the problem
    can you lock in this post and thx for try
    I'm not admin...anyway, thanks for the update
    Whatever you are, be a good one

  7. #7

    Default Re: Array problem i glad for help

    Hi,

    You have to apply for-loop statement, if want to print arrays value(5 values..) which you have decalared in private static void printarr(int[] arr). See this :

    private static void printarr(int[] arr) {
    for(int i=0;i<arr.length;i++)
    {
    System.out.println(" "+arr[i]);
    }
    }


    then, in the main method, you have to put array variable in printarr(int[] arr) method. See this :

    public static void main(string args[]) {
    int[] arr = new int[5];
    printarr(arr);
    }

Similar Threads

  1. Hi everyone - glad to be here
    By jererzia in forum Member Introductions
    Replies: 1
    Last Post: June 13th, 2013, 12:38 PM
  2. Glad to be here!
    By daniel.j2ee in forum Member Introductions
    Replies: 1
    Last Post: October 24th, 2011, 09:00 AM
  3. Hi everyone.. Glad to be here
    By jzarapsa in forum Member Introductions
    Replies: 2
    Last Post: October 16th, 2011, 10:45 PM
  4. Replies: 2
    Last Post: May 13th, 2011, 03:08 AM
  5. Hi!!!I'm glad to be here!!
    By Christos75 in forum Member Introductions
    Replies: 6
    Last Post: July 1st, 2009, 05:12 AM