Hi, I am zeeni...........thanks for ur post..........i tried making the changes below........what did u mean by initializing.....u mean i should write double ro=0;? can u check if my code below is right? Also i noticed a strange thing while compiling....despite i changed the code from int to double radius1 ...my compiler shows Error int radius1..............why is it not updating the compilation?
class Circle
{
double radius1;
Circle(double rad)
{
radius1=rad;
}
double getRadius()
{
double ro;
ro= input.nextdouble(); //Read radius from user
radius1=ro;
return(radius1);
}
double getArea()
{ double area;
area=Math.PI*radius1*radius1;
return(area);
}
double getCircumference()
{ double circumference;
circumference=2 * Math.PI * radius1;
return(circumference);
}
}
I mean,
double getRadius()
{
double rad;
return(rad);
}
If i will call the getRadius() method, thus it returns a real value? what value?
About my previous post, i try it to refer to assembly, Sorry if you couldn't understand some phrase there...
But here is the logic,
If your house is getRadius() and you and your family's surname is rad,
I would like to call you but i don't know your name, just the surname shouting outside your house, rad?!! rad?!! would your parents go outside to find out who's calling? is it for you? is it for your parents?
They don't really know because i call you rad, since that is you surname(Assuming), so, i must call your name just to catch only your attention and not disturbing the others...
In assembly, we must put every data in a stack in every mov, because, The system always uses those registers priority to there processes...
If JVM let this allow, probably the rad might initialized any of the data being stored in a stack... for example, the system stores a hexadecimal value 0AFF,
and your code needs only a 5 double value, then the flow of your program is incorrect, according to your code, wondering why is it happening...
for example,
int value = double value + int value;
is it correct? JVM doesn't allow this because the range of int is much smaller that a double value... i can't remind, JoshaH knows this...
if this will be allowed, the result value at int value will receive a wrong format of bit...