1 Replies - 1721 Views - Last Post: 30 March 2009 - 08:08 PM Rate Topic: -----

#1 garrettcampbell  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 30-March 09

BankAccount Objects stored in arrayList. the get() is returning an obj

Posted 30 March 2009 - 03:10 AM

this is a method that is being called by main.
I have a BankAccount super class and some subclasses of Bank Account that all work fine.
If I try to access the data in a ArrayList of bank account objects directly from main, everything is good. If I try to have a method do it instead and pass the ArrayList to the method, my attempts to access the objects are met with compiler statements about incompatible types. I thinks it must have something to do with how the ArrayList is passed to the method, but I am not sure how to solve this problem

this is the method that is called from main

public static void verifyAccount (String acctName, ArrayList accountDataBase)
{
BankAccount b = new BankAccount();
for(int i = 0; i< accountDataBase.size(); i++)
{
b = accountDataBase.get(i); //this line generates compiler error
......more code
}
}

When I compile this, I am told of an incompatible type: found is a java lang object, but what is needed is a BankAccount object.

when I defined "b" as in the following code
Object b = new Object(), it compiled, but it's worthless since I don't know what to do with it. Totally stuck. Any help appreciated.
Thanks.

This post has been edited by garrettcampbell: 30 March 2009 - 03:15 AM


Is This A Good Question/Topic? 0
  • +

Replies To: BankAccount Objects stored in arrayList. the get() is returning an obj

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8329
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: BankAccount Objects stored in arrayList. the get() is returning an obj

Posted 30 March 2009 - 08:08 PM

Please respect rule #4 of this forum that was shown to you when you post that question
:code:
Go back and edit your post to follow this forum posting rules
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1