how i suppost to do it
i want my main
connect to thisprintarr(arr);
what i need to doprivate static void printarr(int[] arr) { int[] arr = new int[5]; }
thank for help
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.
how i suppost to do it
i want my main
connect to thisprintarr(arr);
what i need to doprivate static void printarr(int[] arr) { int[] arr = new int[5]; }
thank for help
have you declare arr in your main ?
Whatever you are, be a good one
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
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);
}