ArrayList using a Generic Type Issue

I am having issues with capturing necessary data that has been placed into an ArrayList using Generics. This should be a very simple task but apparently the process is not behaving properly. I am using the JDeveloper IDE ver ( So onward to the demonstration of the problem.

I have a class called:
class InstitutionAidValue -[Class is comprised with setter and getter methods]
    private BigDecimal amount;
    private Boolean countIndividual;
    private Boolean countSport;
    private int sourceCode;

I have another class that processes a range of information and then sends all of the elements that were set in InstitutionAidValue over to another class to perform the delivery of the data elements:
class Student-[This class will gather all of the data from the fields in InstitutionAidValue and store into another Array of type InstitutionAidValue]

  //Create array list of data for financial aid value
  List<InstitutionAidValue> instituteList = new ArrayList<InstitutionAidValue>();

Begin the process of populating my ArrayList with values from InstitutionAidValue
                        if (rset.getInt("ATROOM_CODE") != 0) {
                            System.out.println("ATROOM CODE THAT IS SET" + ' ' + institutionAid.getSourceCode());
                            System.out.println("ATROOM AMT THAT IS SET" + ' ' + institutionAid.getAmount());


--I begin to look to determine the size of the ArrayList once it has been populated with the supposed values
                        if (instituteList.size() > 0 ) {
                            System.out.println("Institute List has values");
The message in this case does not even display, so I would imagine that the elements did not populate into the ArrayList even though that I know they exist. I have used getter methods to display in my log file. HELP!!!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

how about using a debugger? thins like this can be solved easily with a debugger.
As you say, instituteList must be empty.

Given your code has this test:
 if (rset.getInt("ATROOM_CODE") != 0) {

the implication is that either
     a) rset.getInt("ATROOM_CODE") is always 0
or b) you're not calling that code at all

I'd make sure that if statement is being executed (add a System.printout before it) and then I'd post the code for getInt() and maybe we can help.


P.S. If you're comparing Strings inside the getInt() method, make sure you are using the "equals" method, so:
string1.equals(string2) ;   // This works
string1 == string2 ; // This doesn't work
SeaghostAuthor Commented:
Ok, I have already setup my System.out.println message throughout the code and I do see that the values are in my ArrayList. However; when I go through my ArrayList with the simple FOR LOOP, it appears that the values that are set, are exactly the same. If I am accepting an OBJECT Type into my array, wouldn't the Array List have different values if I am adding the values through my If Statements?
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

SeaghostAuthor Commented:
P.S. - What I mean from my above post is if I have an object that has 4 fields, when I add that object to my ArrayList, I should be able to see the different values for that object that I have added correct?
mccarlIT Business Systems Analyst / Software DeveloperCommented:
I can't be 100% sure from the small amount of code that you have posted but I think the problem is that you are inserting the same object into your list but changing the values each time around. So, at some point you must have a line of code something like this...

InstitutionAidValue institutionAid = new InstitutionAidValue();

But my guess is that that line is OUTSIDE your loop that processes each row of the resultset. You need to move that line to be INSIDE the loop (by the looks of your code it could go between the IF statement and the call to .setSourceCode)

Basically that line of code creates a new object and so it has to be inside the loop so a new object can be created each time around the loop otherwise there is only ONE object that just gets it's values changed each time around the loop, irrespective of the fact that you are adding it to the list each time. An object can still change, even when it has already been added to the list.

Now this doesn't solve the initial question of why you didn't even get the message printed for having .size() > 0 but can I assume that you solved that issue since your last posts indicate that your list is now populated?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SeaghostAuthor Commented:
This was exactly the cause of my issue and your explanation was on point. Thank You So Much
mccarlIT Business Systems Analyst / Software DeveloperCommented:
You're welcome, glad to help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.