Returning arrays in Java

0 votes

I am trying to return an array using the below code. But I can't find a proper way to get this to work. What can I do?

My code

public class trial1{

    public static void main(String[] args){
        numbers();
    }

    public static int[] numbers(){
        int[] A = {1,2,3};
        return A;
    }
}
Aug 11 in Java by krishna
• 2,640 points
20 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java

0 votes
2 answers

How to concatenate two arrays in Java?

public <T> T[] concatenate(T[] a, T[] b) ...READ MORE

answered Jul 19, 2018 in Java by Sushmita
• 6,900 points
1,993 views
+1 vote
1 answer

Are arrays equivalent to objects in Java ?

Yes; the Java Language Specification writes: In the Java ...READ MORE

answered May 10, 2018 in Java by Rishabh
• 3,620 points
512 views
0 votes
1 answer

Arrays are passed by value or passed by reference in Java?

Arrays are not a primitive type in ...READ MORE

answered Jul 18, 2018 in Java by sophia
• 1,400 points
6,944 views
0 votes
0 answers

Multidimensional Arrays lengths in Java

How can I determine the lengths of ...READ MORE

Aug 8 in Java by krishna
• 2,640 points
27 views
0 votes
0 answers

How do I fill arrays in Java?

Is there a proper way to fill ...READ MORE

Aug 12 in Java by krishna
• 2,640 points
24 views
0 votes
0 answers

How are arrays implemented in java?

In Java, arrays are implemented as objects, ...READ MORE

Aug 18 in Java by krishna
• 2,640 points
29 views
0 votes
2 answers

How an object array can be converted to string array in java?

System.arraycopy is the most efficient way, but ...READ MORE

answered Aug 8, 2018 in Java by Sushmita
• 6,900 points
3,134 views
0 votes
2 answers

How does random shuffling of an array

Here is a simple way using an ArrayList: List<Integer> ...READ MORE

answered Nov 2, 2018 in Java by Sushmita
• 6,900 points
264 views
0 votes
0 answers
0 votes
0 answers

Java : Sort integer array without using Arrays.sort()

I have this assignment- Write java program ...READ MORE

Aug 2 in Python by krishna
• 2,640 points
66 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP