Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6118505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:26:40+00:00 2026-05-23T15:26:40+00:00

OK so what if i have a method like: Object[] myTest(int[] a, double[] b){

  • 0

OK so what if i have a method like:

Object[] myTest(int[] a, double[] b){
   return new Object[]{a,b};
}

Now How can i cast the result Object to int[] and double[]?

Like if i use:

int[] array1 = (int[]) myTest(a,b)[0];
double[] array2 = (double[]) myTest(a,b)[1];

But this does not work. Or is there any efficient method to do this job?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:26:41+00:00Added an answer on May 23, 2026 at 3:26 pm

    Not sure why you’re having difficulty: on Java 6 this works as expected.

    Try compiling this class and running it:

    public class t1
    {
        public static void main(String[] args) throws Exception
        {
        int[] a = new int[1];
        double[] b = new double[1];
    
        int[] array1 = (int[]) myTest(a,b)[0];
        double[] array2 = (double[]) myTest(a,b)[1];
        System.err.println(array1);
        System.err.println(array2);
        }
    
        static Object[] myTest(int[] a, double[] b){
        return new Object[]{a,b};
        }
    }
    

    it will print out

    [I@3e25a5
    [D@19821f
    

    That’s the autoboxing taking place, but will still work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method where I would like to return an object instance of
If I have a method like this: public void DoSomething(int Count, string[] Lines) {
I have a JSON string and I'd like to use to compose an object.
I have a method like this: -(void)A:(int)a B:(int)b{ } and want to put the
I have a method like below ↓ static T GetItemSample<T>() where T : new
I'm creating my own JavaScript Array-like object and I have methods that call closures.
When using something like object.methods.sort.to_yaml I'd like to have irb interpret the \n characters
Is there any method like the array_unique for objects? I have a bunch of
I'd like to be able to call getProgram on objects which have that method,
Assume we have a method like this: public IEnumerable<T> FirstMethod() { var entities =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.