Hello,

I'm new to Java, and reading Intro to Java Programming for Dummies, and I was just wanting to clarify something about creating and referring to objects. This is my first post, so please forgive any formatting blunders..

Here is the code (from pg. 333):
import java.util.Scanner;
 
class ProcessPurchasesss {
 
   public static void main(String args[]) {
      Scanner myScanner = new Scanner(System.in);
      Purchase aPurchase;
 
      for (int count = 0; count < 3; count++) {
         aPurchase = new Purchase();
          System.out.print("Amount: ");
         aPurchase.amount = myScanner.nextDouble();
         System.out.print("Taxable? (true/false) ");
         aPurchase.taxable = myScanner.nextBoolean();
 
         if (aPurchase.taxable) {
            aPurchase.total = aPurchase.amount * 1.05;
         } else {
            aPurchase.total = aPurchase.amount;
         }
 
         System.out.print("Total: ");
         System.out.println(aPurchase.total);
         System.out.println();
      }
   }
}

My question is -> if one creates multiple objects all assigned to the same variable (in this case 'aPurchase') how does one refer to each individual object variable? so if I referred to aPurchase.total, I'd only get the last assigned value right?

many thanks!
Nick