troubleshooting Question

Java return problem

Avatar of clivecrawdevil
clivecrawdevil asked on
Java
9 Comments1 Solution203 ViewsLast Modified:
Hi Experts

I'm very new to Java and have been working on a simple program. Unfortunately I cannot get it to print the returned value using System.out.println();

I'm sure i am making a simple mistake but i'm having trouble finding how to call the value returned by my method.

Would appriciate any help i can get.

My code is

public class First
{
    static int[] first(int[] arr, int n){
      int[] newArr = new int[n];
      for(int i=0; i<n; i++){
          newArr[i] = arr[i];
      }
      return newArr;
    }
    public static void main(String[] args){
      int[] arr = first.newArr;
      System.out.println();
    }
}

Could some please explain how the returned values a called from the method first also please?

Thanks

Clive
ASKER CERTIFIED SOLUTION
sciuriware

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros