File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes why dont compile? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why dont compile?" Watch "why dont compile?" New topic
Author

why dont compile?

ruth angel
Greenhorn

Joined: Aug 30, 2006
Posts: 14
I have this simple class but doesnt want to compile. What is missing?
The program says:

there is a error: Customer first = new Customer(String company, String person, String id, String location);

What am I doing wrong? Thank you so much for any advice.


class Customer{
private String companyName;
private String customerContactName;
private String customerID;
private String address;

//default customer
Customer()
{
companyName= "Knows Toys";
customerContactName = "Lester Jones";
customerID = "000";
address = "(Internal Shipment) Chicago, Illinois";
}
//.......................
Customer(String company, String person, String id, String location)
{
companyName= company.trim();
customerContactName = person.trim();
customerID = id.trim();
address = location.trim();
}

public String createShippingLabel()
{
String label = "\n" + companyName + " (Customer Order Number: " + customerID +
")\n" + customerContactName + "\n" + address;
return label;


// Shipping lable
Customer first = new Customer(String company, String person, String id, String location);
System.out.println(first.createShippingLabel());


//call on the display method
System.exit(0);
}


}
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
When you call a method, you don't list the type of the parameters.
ruth angel
Greenhorn

Joined: Aug 30, 2006
Posts: 14
Hi keith,

keep saying the same thing.

Customer first = new Customer(String company, String person, String id, String location);
^
1 error

Process completed.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
You are still listing the type of the parameters.
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
Yes, declaration and invocation are different.

Looks to me like you are invoking the constructor:



Takes some getting used to - read carefully, apply repetitive coding effort.

Nowadays, I just slap some code up there and see what the compiler says about it, then go read books or documentation on the diagnostic supplied by the compiler.

Really speeds up development time.


"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
ruth angel
Greenhorn

Joined: Aug 30, 2006
Posts: 14
thank you very much
Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
Hi ruth angel,

The code : Customer first = new Customer(String company, String person, String id, String location);

the error that is you are Declaring Customer(String company, String person, String id, String location);

but the code you DID to in the program is to Invoke the Constructor so it should be like this : Customer first = new Customer(company, person, id, location);

regards
KKH


if (!WorkHard){
System.out.println("Fail!!!");
}
 
 
subject: why dont compile?
 
Similar Threads
Difference between object and instance
what is the problem here?
help please error message
Compiler Error: cannot find symbol
what am I doing wrong? help please