Alexander Danilou wrote:My guess is because first code actually doing somenting in infinite loop then some register is overflowing faster and JVM makes forced exit. Second code (commented s.o.p) uses less memory (I think).May be given some time - hours? it will still spit Hello...
Ankit Garg wrote:
There are some ways to confirm it but I don't want to confuse you...
Ankit Garg wrote:you cannot access the value of a field before its declaration (as Mahima mentioned). That's why you are getting an error. Try these too
Christophe Verré wrote:This time, you removed the local variable. But there is still a static variable called "a" accessible for the main method, which is another primitive. The problem comes from that the class has a crappy name . It's also called "a". When you call a.a, the compiler doesn't understand that you want to reference the "a" variable of class "a". It looks in the narrowest scope, sees a static int, and belches an error message.
Christophe Verré wrote:
can anyone explain why that code is error while compiling??
In the main() method, there is a local variable called "a". It's a primitive, so trying to call "a.a" won't work.
Khalid A. Mughal wrote:And then again some people shoot ducks!
My sympathy is with the ducks, regardless of their fate.
I sincerely hope that ducks are not a metaphor for authors of certification books!
Ruben Soto wrote:This is one of the reasons why you should enclose any wait() invocations in a while loop which checks for a relevant condition to make sure that whatever the thread was waiting for has actually happened.
armando fonseca wrote:
Rafael Angarita wrote:Hello Vishal,
When we are talking about primitives, implicit cast happens when you do a widening conversion. A narrowing conversion NEEDS a explicit cast, and you are trying to do a narrowing conversion without a cast.
There s a special situation that you don't need explicit casting, here is:
Let say that here is the semantic of a variable: <target type> <variable name> = <source>;
1. When the source is a constant is an int, byte, short, char within in range of the target type.
2. When the target type is either byte, short or char.
Ruben Soto wrote:Steven, can you try compiling from the command line using javac?