Why won't this work?? ----------------------------------- import java.util.Vector; public class Customer { public Vector bankCustomers; String first_name, last_name; long phone_number;
public Customer() { bankCustomers=new Vector(); }
public void newCustomer(String Fname, String Lname, long phoneN) { this.first_name=Fname; this.last_name=Lname; this.phone_number=phoneN ;
//Adds the new Customer to the BankCustomer Vector. bankCustomers.addElement(newCustomer(Fname,Lname,phoneN)); } }
------- ------------------------------------------- this is the error.
--------------------Configuration: JDK version 1.3 <Default>------------------------------------------------ C:\Program Files\Xinox Software\JCreator\MyProjects\Customer.java:20: 'void' type not allowed here bankCustomers.addElement(newCustomer(Fname,Lname,phoneN)); ^ 1 error Process completed.
Watch your code again.. Vector 's addElement takes Object as a parameter and your method is returning a "void".. Also the addElement method should be placed outside the method body "newCustomer"..