I am having trouble compiling the following piece of code, it keeps giving me an error talking about an possible loss of precision. I know i could replace the one line to:
private float someNum = 0;
but i don't like that becuase it is assigning an int to a float ... yes yes i know that the compiler will use coersion and cast it off to a float, but is there a way around this?!?

class test 
{
   private float someNum = 0.0;
   public static void main(String[] args) {}
}

Floating point literals in Java are always of type double unless you take care to tell the compiler they're of type float.
Double is a 64 bit floating point number, float is a 32 bit number.

Either change the type to double or change the initial value to 0.0f

And while you're at it follow the Java class naming conventions and
1) name your class in CamelCase, starting the name with a CAPITAL letter
2) use packages. While not a problem yet there are many uses where things don't work well unless you use a package.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.