Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Can u tell me what this sentence means? pArea = new polyArea(this,(float)10000.0). i want to kn

  Asked By: Aditi    Date: Nov 12    Category: Java    Views: 938
  

i am java beginner. Can u tell me what this sentence means?
pArea = new polyArea(this,(float)10000.0). i want to know the part
inside the brackets..
Thanx

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Bathilda Schmidt     Answered On: Nov 12

The polyarea constructor accepts an object and float parameter. Since "this" is
passed as a parameter instead of an actual class object, it shows polyarea
constructor should have been called within some class member methods(non static)
and the constructor accepts that class object as a parameter.

 
Answer #2    Answered By: Joyce Edwards     Answered On: Nov 12

also, the (float) part sets the number following it to a float. it is called
type casting, and is useful for objects as well as predefined types.

 
Answer #3    Answered By: Adel Fischer     Answered On: Nov 12

Can you tell me what does
float(10000.0) mean?

 
Answer #4    Answered By: Teresa Rogers     Answered On: Nov 12

This is the code you gave me earlier:
pArea = new polyArea(this,(float)10000.0)
The section of the code (float)10000.0 is saying that you want to ensure that
the number 10000.0 is stored as a float. The reason for this is because methods
require numbers to be a certain form, whether it be float, double, int, etc.
This is just making sure it is a float. the same could be 10000.0f. so the code
could look like this instead:
pArea = new polyArea(this, 10000.0f);

 
Answer #5    Answered By: Tammy Sanders     Answered On: Nov 12

It is

pArea = new polyArea(this,(float)10000.0)

not float(10000.0)

the default type of floating point number is double. Since you need float then
you have to cast double into float.