This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!

Henry Wong

author
+ Follow
since Sep 28, 2004
Henry likes ...
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
Forum Moderator
Henry Wong currently moderates these forums:
New York City
Cows and Likes
Cows
Total received
141
In last 30 days
0
Total given
667
Likes
Total received
2234
Received in last 30 days
0
Total given
328
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Henry Wong


First, a big thanks to Hanumant Deshmukh for being here to promote OCP Oracle Certified Professional Java SE 11 Programmer I Exam Fundamentals 1Z0-815.

The winners are:

   Ranjith Kumar Kumar
   Geff Chang
   Adrian Grabowski
   Elias Khan

Please send your snail mail address to bookpromotion AT javaranch DOT com. To ensure the quickest response, please provide the following:

Your name (first and last - if your CodeRanch name is different, please include both your real name and Ranch name)
Email
Country (needed even if requesting an e-book)


Also, please include the following as the subject of your Email.

Promo Winner - OCP Oracle Certified Professional Java SE 11 Programmer I Exam Fundamentals 1Z0-815 - Tuesday, September 10th, 2019


Image from https://images-na.ssl-images-amazon.com

As noted in the Book Promotion Eligibility Requirements and Legal type stuff, the winners have 8 days to submit their information. Within 3 days of receipt of your email, we will reply to let you know we got it. If you don't hear back, the goat might have eaten your email. Please let us know by posting in the Ranch Office so we can check on it. Once you have received your copy please let us know by editing the Book Promotions Winners Page and updating the 'Status' column to say you have it.

Thanks and congrats to all the winners.

This week, we're delighted to have Hanumant Deshmukh helping to answer questions about the new OCP Oracle Certified Professional Java SE 11 Programmer I Exam Fundamentals 1Z0-815.


The promotion starts Tuesday, September 10th, 2019 and will end on Friday, September 13th, 2019

We'll be selecting four random posters in this forum to win a free copy of the electronic book/resource provided by the publisher, Enthuware .


Image from https://images-na.ssl-images-amazon.com

Please see the Book Promotion page to ensure your best chances at winning!

Posts in this welcome thread are not eligible for the drawing, and should be reserved for welcoming the author. Questions posted in this topic are subject to removal.

First, a big thanks to Alexander Dean & Valentin Crettaz for being here to promote the book Event Streams in Action.

The winners are:

   Babi Astimal Astimal
   Stephan van Hulst
   Raghunatha Reddy
   Marco Schoolenberg

Please send your snail mail address to bookpromotion AT javaranch DOT com. To ensure the quickest response, please provide the following:

Your name (first and last - if your CodeRanch name is different, please include both your real name and Ranch name)
Email
Country (needed even if requesting an e-book)
Address
Phone Number


Also, please include the following as the subject of your Email.

Book Promo Winner - Event Streams in Action - Tuesday, August 20th, 2019


Image from https://m.media-amazon.com

As noted in the Book Promotion Eligibility Requirements and Legal type stuff, the winners have 8 days to submit their information. Within 3 days of receipt of your email, we will reply to let you know we got it. If you don't hear back, the goat might have eaten your email. Please let us know by posting in the Ranch Office so we can check on it. Once you have received your copy please let us know by editing the Book Promotions Winners Page and updating the 'Status' column to say you have it.

Thanks and congrats to all the winners.
1 month ago

This week, we're delighted to have Alexander Dean & Valentin Crettaz helping to answer questions about the new book Event Streams in Action.


The promotion starts Tuesday, August 20th, 2019 and will end on Friday, August 23rd, 2019

We'll be selecting four random posters in this forum to win a free copy of the book provided by the publisher, Manning Publications.


Image from https://m.media-amazon.com

Please see the Book Promotion page to ensure your best chances at winning!

Posts in this welcome thread are not eligible for the drawing, and should be reserved for welcoming the author. Questions posted in this topic are subject to removal.
1 month ago

Bhupinder Verma wrote:It sound funny that I am replying on this post after so long, but it may be helpful to someone else stuck with similar sort of problem.

Any feedback is highly appreciated.



Wow. After five years? That's dedication... Have a cow ...

Henry
2 months ago

Sanjana Senthil wrote:
Hey everyone, I keep getting a syntax error for the else statement....i'm pretty sure my curly brackets are fine .....help would be very appreciated!



There is no such a thing as a while-else statement (meaning else following while) in Java.

Henry
3 months ago

Vaibhav Gargs wrote:
Hi Campbell, I am not sure if any such CPU exists but since these are some special instructions such as CAS etc. which made me think that these instructions will be supported by all CPUs or not?



The CAS instruction is supported by all modern day processors. Keep in mind that the CAS instruction is also needed by the JVM to implement synchronization, so, if the CAS instruction doesn't exist (like with really old JVMs), then a work around has already been implemented.

Henry

Arun Singh Raaj wrote:what kind of lock system does AtomicInteger uses?



The AtomicInteger class uses a technique call "optimistic locking". This means that there isn't any locks...  

Instead, there is a mechanism that is used to detect collisions -- and of course, if it does collide, then there is a mechanism to resolve it (which is just to retry the operation, in most cases). The idea is... since a collision will not happen for a majority of cases, it will run really fast (since there isn't any locks).

Henry

First, a big thanks to Roberto Infante for being here to promote the book Building Ethereum DApps: Decentralized Applications on the Ethereum Blockchain.

The winners are:

   Michael Krimgen
   Joe Cortee
   paul nisset
   ludoviko azuaje

Please send your snail mail address to bookpromotion AT javaranch DOT com. To ensure the quickest response, please provide the following:

Your name (first and last - if your CodeRanch name is different, please include both your real name and Ranch name)
Email
Country (needed even if requesting an e-book)
Address
Phone Number


Also, please include the following as the subject of your Email.

Book Promo Winner - Building Ethereum DApps: Decentralized Applications on the Ethereum Blockchain - Tuesday, May 14th, 2019


Image from https://m.media-amazon.com

As noted in the Book Promotion Eligibility Requirements and Legal type stuff, the winners have 8 days to submit their information. Within 3 days of receipt of your email, we will reply to let you know we got it. If you don't hear back, the goat might have eaten your email. Please let us know by posting in the Ranch Office so we can check on it. Once you have received your copy please let us know by editing the Book Promotions Winners Page and updating the 'Status' column to say you have it.

Thanks and congrats to all the winners.
4 months ago

This week, we're delighted to have Roberto Infante helping to answer questions about the new book Building Ethereum DApps: Decentralized Applications on the Ethereum Blockchain.


The promotion starts Tuesday, May 14th, 2019 and will end on Friday, May 17th, 2019

We'll be selecting four random posters in this forum to win a free copy of the book provided by the publisher, Manning Publications.


Image from https://m.media-amazon.com

Please see the Book Promotion page to ensure your best chances at winning!

Posts in this welcome thread are not eligible for the drawing, and should be reserved for welcoming the author. Questions posted in this topic are subject to removal.
5 months ago
Integer objects are immutable. You can't just increment it. When you do that in Java, the compiler will generate code (as syntactic sugar) to unbox, increment, and box the value again. This means that it is a completely different object after the increment.

And in your application, which has different references pointing to what was originally the same object -- they are now different references pointing to different objects (with different values).

Henry

John Losty wrote:

Then at runtime, order of evaluation is always left to right: ...



also this isn't clear to me as at some point he stopped evaluating from left to right and first evaluated inside brackets.



Actually, this is not true. Others have already posted information on how to interpret the evaluation, so, I will not continue on that... except to add...

Evaluation to completion are not equal -- meaning it takes longer to complete evaluation of a longer sub expression (either with parenthesis, or added parenthesis which were done to respect precedence/associativity). When the Java specification states that the evaluation is done "left to right" (in addition to the rules on respecting precedence/assoc, parameters, etc.), it is referring to when the evaluation of the sub expression starts -- and not when it completes.

If you review Stephen's example again, and look at when the evaluation starts, you will see that he is indeed, evaluating left to right.

EDIT: Okay, in reviewing again, it may not be that easy to see. If I have time later, I will do a quick write up, and the start points, and how it is left to right.

Henry
5 months ago

John Losty wrote:

in this case (after respecting parens, precedence, and assoc), requires that the left operand be evaluated before the right operand.

How do you apply it?



Stephen already showed you how it is done. He converted all the precedence/assoc rules into parenthesis -- so, it is easier to apply. Then, he showed you how it was done (evaluated) -- meaning the parens are used to determine the left and right operands for evaluation.

Henry
5 months ago