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 8595839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:32:06+00:00 2026-06-12T00:32:06+00:00

I was wondering if it is possible to convert an Object into something else.

  • 0

I was wondering if it is possible to convert an Object into something else.

I have a Object which contains a series of numbers in a random order such as: 3, 4, 2, 5, 1 and wondering if I am able to turn it into an int[] or select certain elements from it, as in a number from the sequence?

EDIT:
so some of the code i have is:

//This contains all the different combinations of the numbers
ArrayList routePop4 = new ArrayList();
//This picks out the first one, just as a test
Object test = routePop4.get(0);

But the idea is that I want to loop through each element of test.

  • 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-06-12T00:32:08+00:00Added an answer on June 12, 2026 at 12:32 am

    An Object cannot “contain a series of numbers”. However many subclasses of Object, such as all of the Collections can “contain a series of numbers”, and they come with a toArray() method to turn the contents of the collection into an array.

    If you have a collection, but only have access to it as an Object, you need to cast it before you can work with it properly:

    ArrayList<Integer> list = (ArrayList<Integer>)test;
    Integer[] arr = list.toArray(new Integer[]{});
    

    It’s fairly rare in day-to-day Java to actually be working with variables cast as Object, if you are, it should be a red flag that you may be doing something wrong. You can use generics to allow objects that contain other objects to do so generically, like so:

    ArrayList<Integer> list = new ArrayList<Integer>();
    list.add(1); // Can only add integers, list.add("a string") would fail at compile time
    int n = list.get(0); // no need to cast, we know list only contains Integers
    

    If you aren’t using a Collection, you’ll presumably need to roll your own, as Luke Taylor’s answer suggests. That said, you’ll get better answers if you can provide more information, the current text of your question doesn’t make sense in a Java context.

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

Sidebar

Related Questions

I'm just wondering...is it possible to use Java to convert a .mp3 file into
Just wondering whether it is possible to convert highly normalized data into binary and
I'm wondering if is possible to convert this HQL query into a criteria api
I was wondering if its possible to convert a number into a string using
I have a web service call that returns XML which I convert into domain
I was wondering if it is possible to convert a wpf application to silverlight
Just wondering in php, if it was possible to convert a string to a
Hey, I'm just wondering if it would be possible to convert videos to mp3
I am wondering if its possible to have a an (||)or or (&&)and operator
I was wondering if it's possible to convert the string StackTrace in the exception

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.