File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why won't this compile?

 
Elaine Banks
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1365
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Elaine Banks
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Muchas Gracias.
You guys are the best!!
EB
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic