• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Why won't this compile?

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Muchas Gracias.
You guys are the best!!
EB
 
Your mother is a hamster and your father smells of tiny ads!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic