Puzzling Java statement of the day

Some days ago I stumbled across a Java statement which I thought was trivial at first, only to discover that I had no idea. I have a reasonable understanding of what a JVM does and how Java bytecode is executed. But as this example shows once again, that doesn’t necessarily spread to the Java programming language. The snippet below should explain my point.

int lorem = 1, ipsum = 2, dolor = 3;
if (lorem == (lorem = ipsum))
	f();
if ((ipsum = dolor) == ipsum)
	g();

Which of the above two methods f() and g() is actually invoked? Can you tell without compiling the code? Possible answers are:

  • None of the two methods get invoked, both call-sites are dead code.
  • Just f() is invoked and the call-site of g() is dead code.
  • Just g() is invoked and the call-site of f() is dead code.
  • Both methods are invoked, the conditions are pointless.

Ironically, I finally understood what was going on after looking at the generated bytecode (good old javap is your friend). I am not posting the disassembled code because that would spoil the fun. But once you look at it, the answer appears to be quite obvious.

Thank you for the great

Thank you for the great content you shared.

This piece of writing will

This piece of writing will help the internet
people for creating new blog or even a blog from start to end.

What are the trending

What are the trending destinations in France at the present? We can easily find all info on https://www.thingstodopost.org/ with detailed article.

good.

good.

This is a classic example of

This is a classic example of how the order of evaluation and assignment can impact the outcome of expressions in programming languages. The use of such constructs is generally discouraged for the sake of code readability and maintainability. Understanding the generated bytecode helps unveil the logic behind this behavior.

You have a great content!

You have a great content! Thanks for sharing

Your style is really unique

Your style is really unique compared to other people I've read stuff from.
Thank you for posting when you've got the opportunity, Guess I'll just bookmark this
web site.

Magnificent site. A lot of

Magnificent site. A lot of helpful info here.
I am sending it to several pals ans also
sharing in delicious. And obviously, thank you in your effort!

I pay a quick visit each day

I pay a quick visit each day some web sites and websites to read articles, however this website gives quality
based articles.

Great blog here! Also your

Great blog here! Also your web site rather a lot up very
fast! What web host are you the usage of?
Can I get your affiliate link on your host? I want
my site loaded up as fast as yours lol

I'm so happy with the

I'm so happy with the content! Thanks

wonderful points altogether,

wonderful points altogether, you just won a new reader.
What may you suggest about your publish that you simply made some days ago?
Any sure?

Hello, after reading this

Hello, after reading this remarkable article i am also cheerful
to share my experience here with colleagues.

This is very interesting, You

This is very interesting, You are an overly professional blogger.

I've joined your rss feed and look ahead to seeking more of your magnificent
post. Also, I've shared your site in my social networks

Excellent, what a web site it

Excellent, what a web site it is! This website presents valuable
information to us, keep it up.

Admiring the hard work you

Admiring the hard work you put into your blog and detailed
information you offer. It's great to come across a blog every
once in a while that isn't the same outdated rehashed material.

Excellent read! I've saved your site and I'm including your RSS feeds to
my Google account.

You have a good details!

You have a good details! Thanks

Great post. I used to be

Great post. I used to be checking constantly this weblog and
I am impressed! Extremely useful information specifically the remaining part :
) I deal with such information much. I was
looking for this certain information for a long time. Thank you and best of luck.

You have a good content!

You have a good content! Thanks

My relatives always say that

My relatives always say that I am killing my time here at net, but I know I am getting knowledge everyday by reading such nice articles or reviews.

Have you ever considered

Have you ever considered publishing an ebook or guest authoring on other
blogs? I have a blog based upon on the same subjects you discuss and would really like to have you share some stories/information. I know
my subscribers would appreciate your work. If you are even remotely interested, feel
free to shoot me an e mail.

Have you ever considered

Have you ever considered publishing an ebook or guest authoring on other
blogs? I have a blog based upon on the same subjects you discuss and would really like to have you share some stories/information. I know
my subscribers would appreciate your work. If you are even remotely interested, feel
free to shoot me an e mail.

Thanks for this information!

Thanks for this information! Keep it up

What's up, after reading this

What's up, after reading this awesome paragraph i am also glad to share my knowledge here with mates.

For newest news you have to

For newest news you have to visit world wide web and on the web
I found this website as a best web site for most recent updates.

Hi there, You have done an

Hi there, You have done an excellent job. I will definitely digg it and personally suggest to my friends.

I am confident they will be benefited from this website.

You have a nice data! Thanks

You have a nice data! Thanks

You have a good content!

You have a good content! Thanks

I read this article fully

I read this article fully about the resemblance of most up-to-date and earlier
technologies, it's amazing article.

Good way of explaining, and

Good way of explaining, and pleasant paragraph to obtain data regarding my presentation subject
matter, which i am going to present in institution of higher
education.

What's up mates, its great

What's up mates, its great article concerning tutoringand entirely explained,
keep it up all the time.

That is very fascinating,

That is very fascinating, You're an overly skilled blogger.
I've joined your feed and look ahead to in quest of more of your
excellent post. Additionally, I have shared your web site
in my social networks

Quality articles is the key

Quality articles is the key to invite the users to pay a quick visit the site, that's what this site is providing.

I'm so impressed with the

I'm so impressed with the output! Thanks

Hello just wanted to give you

Hello just wanted to give you a brief heads up and let you know a few of
the pictures aren't loading correctly. I'm not sure why but I think its a linking issue.
I've tried it in two different browsers and both show the
same outcome.

Now I am going to do my

Now I am going to do my breakfast, when having my breakfast coming
yet again to read more news.

Now I am going to do my

Now I am going to do my breakfast, when having my breakfast coming
yet again to read more news.

Hello all, here every person

Hello all, here every person is sharing these knowledge, so it's nice to read
this website, and I used to pay a quick visit this webpage
everyday.

Wow! Finally I got a weblog

Wow! Finally I got a weblog from where I be capable of in fact get helpful data
regarding my study and knowledge.

Wow! Finally I got a website

Wow! Finally I got a website from where I can in fact take helpful data
regarding my study and knowledge.

Thanks for any other

Thanks for any other informative website. The place else may I get that kind of info written in such an ideal means?
I've a undertaking that I'm just now running on, and I have
been at the look out for such info.

If some one desires expert

If some one desires expert view about blogging afterward i suggest him/her to pay a quick visit this weblog, Keep up the nice job.

Wow! Finally I got a website

Wow! Finally I got a website from where I can in fact take helpful data
regarding my study and knowledge.

This piece of writing

This piece of writing presents clear idea for the
new viewers of blogging, that truly how to do blogging and site-building.

Asking questions are in fact

Asking questions are in fact pleasant thing if you
are not understanding something totally, except this article gives good understanding even.

Excellent article. I will be

Excellent article. I will be facing some of these issues as
well..

I want to share this content!

I want to share this content! Thanks

I enjoy what you guys are up

I enjoy what you guys are up too. This kind of
clever work and reporting! Keep up the wonderful works guys I've you guys to blogroll.

I must thank you for the

I must thank you for the efforts you have put in penning
this website. I really hope to see the same high-grade content by you in the future as well.
In truth, your creative writing abilities has encouraged me to get my own, personal website now ;)

This is great. I appreciate

This is great. I appreciate the post. Seriously.