sarathy rambha

Greenhorn
+ Follow
since Mar 26, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sarathy rambha

Hi,
I see compilation while compiling below program. But since round(float) returns int, I am not sure why it thinks return type is double.

float ddd = 3.5;
int j = Math.round(ddd);


Math1.java:84: possible loss of precision
found : double
required: float
float ddd = 3.5;
Hi,
In the below program, I am expecting compilation error according to JCP book as m is not declared before using it. But the program works fine and gives output. Can anybody explain how this program works.

public class Init
{
private static String msg(String msg)
{
System.out.println(msg);
System.out.println("Open for all");
return msg;
}


public Init()
{
m=msg("1");
System.out.println("I am near 1");
}

{
m=msg("2");
System.out.println("I am near 2");
}

String m=msg("3");
{
System.out.println("I am near 3");
}

public static void main(String args[])
{
Object obj=new Init();
System.out.println("I am in main1");
}
}