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, 2022 in Java by krishna
• 2,820 points
574 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,920 points
2,924 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
1,346 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
10,430 views
0 votes
0 answers

Multidimensional Arrays lengths in Java

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

Aug 8, 2022 in Java by krishna
• 2,820 points
455 views
0 votes
0 answers

How do I fill arrays in Java?

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

Aug 12, 2022 in Java by krishna
• 2,820 points
600 views
0 votes
0 answers

How are arrays implemented in java?

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

Aug 18, 2022 in Java by krishna
• 2,820 points
624 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,920 points
5,752 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,920 points
926 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, 2022 in Python by krishna
• 2,820 points
2,175 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP