Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   Array of objects (http://www.go4expert.com/forums/array-of-objects-t9350/)

cyrow 15Mar2008 14:54

Array of objects
 
Code:

//class declarations
class Account{
private int        accNum;
private double    balance;
  Transaction trans;

Account(int a, double b, String f, String l){
  accNum = a;
  balance = b;
  Transaction[]trans= new Transaction[10];
}

class Transaction{
private int accNum;
private String date;
  Transaction(int a, String d){
  accNum = a;
  date = d;
  }

Problem
I have two files, "accounts.txt" and "transaction.txt", I am trying to read the transaction data from the transaction file into the main Account.
//Code
Transaction[index].trans[i] = new Transaction(in.nextInt(), in.next());
index = position returned by binarysearch
//error : Transaction cannot be located, what might the problem be? Do I use
Account.Transaction[index].trans[i] = new Transaction(in.nextInt(), in.next());


All times are GMT +5.5. The time now is 17:57.