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 won't this compile? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why won Watch "Why won New topic
Author

Why won't this compile?

Elaine Banks
Greenhorn

Joined: Dec 16, 2003
Posts: 18
public class pool
{
static final int RATE_OF_FLOW = 50;
static final float CAPACITY = 7.5f;
void pool (int L, int W, int D)
{
int volume = (L * W * D);
float time_to_fill = (L * W * D * (CAPACITY/RATE_OF_FLOW*60));
float pool_capacity = L * W * D * CAPACITY;

}

public static void main (String [] args)
{
pool smallPool = new pool (20,12,4);
pool largePool = new pool (30,20,10);

}
}
All input welcome.
Thanks.
EB
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
Constructors in java don't have a void return type. They have no return type at all. Thus you have a function called pool() that takes three arguments, but no constructor that takes three arguments.
WY Hsiao
Greenhorn

Joined: Oct 31, 2003
Posts: 4
If you have a function called pool().

This is the appropriate way to call pool().
Constructors can take three arguments.
If you want to have a constructor which takes three arguments,
you should not use void return type.

A suggestion:
we usually use capital letter for the first letter of a constructor.
(It is the same way as naming a calss)
and we use small letter for the first letter of a method .
so, a constructor and a method will not have the same name.
[ December 28, 2003: Message edited by: WY Hsiao ]
[ December 28, 2003: Message edited by: WY Hsiao ]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Elaine,
Realizing that David has already pointed out the answer, the following is just a suggestion for future posts of this nature.
What compiler error is being displayed? Which line of code does it suggest the problem is on? What are you trying to accomplish on that line of code? Why do you think that the compiler should not be complaining about things at that line of code?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Elaine Banks
Greenhorn

Joined: Dec 16, 2003
Posts: 18
Muchas Gracias.
You guys are the best!!
EB
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why won't this compile?