I’m trying to create a customer. I’m trying to add each user input inside an arrayList and make it output towards the end. But, my output gives me some memory location.Can someone throw some light into this?
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter First Name: ");
String firstName = input.nextLine();
System.out.println("Enter Last Name: ");
String lastName = input.nextLine();
System.out.println("Enter Home Address: ");
String homeAddress = input.nextLine();
Customer cus = new Customer(firstName, lastName, homeAddress);
System.out.println("\nWelcome: ");
System.out.print(cus.getFirstName() + cus.getLastName());
System.out.println("\n Your Shipping Address: ");
System.out.print(cus.getHomeShippingAddress());
List<Customer> customer = new ArrayList<Customer>();
customer.add(cus);
// Output the list contents
printList(customer);
}
public static void printList(List<Customer> list) {
System.out.println("Customers: ");
for (Customer customer : list) {
System.out.printf("%s", customer);
}
System.out.println();
}
}

You’re trying to print an object, so it goes to its
toString()method. You probably want to implement your owntoString()method by overriding the one inherited from Object.Something like:
What you’re currently seeing, inherited from Object, is this: