I am new to java and trying to work on ArrayList. From Main method I want to >pass the ArrayList to another class CustomerAcc. I need help how to pass the >ArrayList and then how to get the ArrayList in the class Customer code here
import java.io.*;
import java.util.*;
import java.lang.Object;
public class CustomerMain {
public static void main(String[] args) throws FileNotFoundException {
ArrayList<String> custName = new ArrayList<String>();
ArrayList<String> custZip = new ArrayList<String>();
double count = 0;
boolean done = false;
System.out.print("Please enter Customer name or 'X' to exit: ");
Scanner in = new Scanner(System.in);
// Gets user input for name and zip code
while (in.hasNext() && !done) {
String checkInput = in.next();
if (checkInput.equalsIgnoreCase("X")) {
done = true;
}
else {
custName.add(checkInput);
System.out.print("Please enter Zip code: ");
custZip.add(in.next());
count++;
System.out.print("\nPlease enter Customer Name or 'X' to `enter code here`exit: ");
}
}
//Sending the user input data to CustomerAcc class
CustomerAcc custRecord = new CustomerAcc(custName, custZip, count);
}
}
The CustomerAcc class :
public class CustomerAcc extends CustomerMain {
public static void CustomerAcc(String custName, String custZip, int count){
}
}