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

  • SEARCH
  • Home
  • 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 6855639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:47:01+00:00 2026-05-27T01:47:01+00:00

I have a arraylist(eg.CustInfo) which contains a collection of objects(Cust_details,Cust_Auth) for java classes, which

  • 0

I have a arraylist(eg.CustInfo) which contains a collection of objects(Cust_details,Cust_Auth) for java classes, which in turn has collection of values for the variables(eg.Cust_name,Cust_addr) defined.

Now my problem is that I have a new class(eg. Priviliged_Cust) which has certain variables whose values have to be taken from the objects added inside the arraylist.

i tried to typecast the arraylist to the new class and get the data using get(index) but it throwed castException.

Please help me with this!!!

Additional Explanation,

First, a query is ran and the result is mapped into the respective variables of the respective class
with the help of setter methods using the instance of an object of that particular class.
then this object is added into Arraylist and the Arraylist is returned.

Second,This happens to a set of queries and the data is mapped to the respective classes and the
object added into the arraylist and the respective arraylists are returned to the respective calling methods.

My Question is, I’ve created a new class which contains the same field as in the previous classes and
it also needed to be mapped to the same variables as the above classes from the arraylist which has the
objects which contains the value of the fields that are needed to be mapped.

Since the queries are returning only the Arraylist, i need to fetch the object from the models and
then i need to match each of the fields respectively.

Hope this information helps.

  • 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-27T01:47:02+00:00Added an answer on May 27, 2026 at 1:47 am

    Don’t use collections to store data that is not related to each other. Use member variables with getters and setters for these values. You can then get whichever value you want by just calling the getter.

    If you want to create a new Object that has some values from your existing data, don’t try to cast your data. Just create the new Object and use constructor parameters to give it its values.

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

Sidebar

Related Questions

I have an ArrayList in Java, which contains Objects, these Objects are made of
I have an arraylist that contains items called Room. Each Room has a roomtype
I have an arraylist which has a class datastructure. public class empRec { public
I have an arraylist which has data structures in it. I am having problems
I have the arraylist which has some process names like Notepad, mspaint I want
I have an ArrayList which I add some Objects to it dynamically, and I
I have an ArrayList of an object which has properties Object.name and Object.url .
I have an ArrayList<String> that I'd like to return a copy of. ArrayList has
I have an arraylist that gets different type of values in it, 1st value->
I have an ArrayList that I want to use to hold RaceCar objects that

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.