Creating array of objects from abstract and subclasses java?

The Problem is with your subclass constructor. You have to explicitly call the desired super class constructor, else the compiler will add super() as the first statement in you subclass constructor. Below is an example import java.util.

Date; public class Test { public static void main(String... abc){ Customer a = new STCustomer20; a0 = new STCustomer(); a1 = new STCustomer(""World",12L,new Date()); a1 = new STCustomer(""World",12L); } } class Customer{ public Customer(){ System.out. Println("Customer()"); } public Customer(String a, String b, long c,Date d){ System.out. Println("Customer(String a, String b, long c,Date d)"); // Set values to fields } } class STCustomer extends Customer{ public STCustomer(){} public STCustomer(String a, String b, long c,Date d){ } public STCustomer(String a, String b, long c){ super(a,b,c,new Date()); } } and output Customer() Customer() Customer(String a, String b, long c,Date d).

The Problem is with your subclass constructor. You have to explicitly call the desired super class constructor, else the compiler will add super() as the first statement in you subclass constructor. Below is an example.

Import java.util. Date; public class Test { public static void main(String... abc){ Customer a = new STCustomer20; a0 = new STCustomer(); a1 = new STCustomer(""World",12L,new Date()); a1 = new STCustomer(""World",12L); } } class Customer{ public Customer(){ System.out. Println("Customer()"); } public Customer(String a, String b, long c,Date d){ System.out.

Println("Customer(String a, String b, long c,Date d)"); // Set values to fields } } class STCustomer extends Customer{ public STCustomer(){} public STCustomer(String a, String b, long c,Date d){ } public STCustomer(String a, String b, long c){ super(a,b,c,new Date()); } } and output Customer() Customer() Customer(String a, String b, long c,Date d).

No, you should not use arrays. Use a List instead and be happy about its simple API. You can use the add and size methods of it, and you don't have to keep track of the size yourself.

You can also have more than 20 customers, and the code will still work. Here is some example code: List customers = Lists.newArrayList(); ... while ((line = bufferedReader.readLine())! = null) { ... customers.

Add(new Customer(...)); } for (Customer customer : customers) { System.out. Println(customer.getId()); }.

It was one of many mistakes I am making. When extending my customer class, I did not add "super(cID, cName, cPhone). This resulted in null being returned.

Class STCustomer extends Customer{ //instance variables private GregorianCalendar stCustJoinDate; //constructor public STCustomer (String cID, String cName, String cPhone, GregorianCalendar stCJoinDate) { super(cID, cName, cPhone ); stCustJoinDate = stCJoinDate; } //accessor public GregorianCalendar getSTCJoinDate() {return stCustJoinDate;}.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions