Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!

Welly Tambunan

Ranch Hand
+ Follow
since Aug 18, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Welly Tambunan

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...

Agree. Try to change the code

Ankit Garg wrote:

There are some ways to confirm it but I don't want to confuse you...

oo.. i see. So i was wrong about that code. Can you give me another way to confirm it?
I'm interesting to take a look at it.

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

but why the bold part is not cause compile error.
we read value of b and assigned to a ..?

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.

ow.. i see. Thanks a lot. All clear now.

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.

I change the code to be like this.. and the result is still compile error.

but if i change that to..

that will be succesfully compiled.


Aakash Goel wrote:I tried this code:

The point is : Is there any way to reference the 'a' at marker_1? [obviously except renaming]

can anyone explain why that code is error while compiling??

Vyas Sanzgiri wrote:Well again, I respect the comment but I do not agree with it

That's fine i think. Different people, different preference. I think that's normal.

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!

I think this thread is the funniest thread in this forum. Like the topic i think.
And maybe that's related to the headfirst formula.
You'll remember the stuff if that is out of the ordinary
Like the poor duck in SCJP Forum.

Vyas Sanzgiri wrote:Some people don't eat Ducks

ow.. so i need to learn all method in API of those classes. Thank you for your explanation.
Is the material in K&B enough to handle a question about API Contents in real exam ?
Thank you very much Devaka. I owe you much.
Once again. Thank you very much.

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.

so i think that's the pattern when we're working on thread. Can you give a reference book about the pattern on multithreading Ruben ?
Thank you berfore.

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.

- Armando

And i think when you return something from the method that's happen too. Isn't it?
Thanks for the link too Vishal.

Ruben Soto wrote:Steven, can you try compiling from the command line using javac?

Yes, that's working in my machine with javac command. But i try to use eclipse and that's give me an error.
Is eclipse using the different javac compiler?