This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Java in General and the fly likes Hello World! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Hello World!" Watch "Hello World!" New topic

Hello World!

sahan thinusha

Joined: Nov 10, 2012
Posts: 10

what's the "condition" so that the following codsnippet prints both "Hello World !"
Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

Not possible. Either the if or the else will be executed. It's not possible to execute both.
Anayonkar Shivalkar

Joined: Dec 08, 2010
Posts: 1541

However, there are ways to do that in C/C++ - but I doubt if that is possible in Java

Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
sahan thinusha

Joined: Nov 10, 2012
Posts: 10

thanks Guys.....!!
Paul Witten
Ranch Hand

Joined: Oct 10, 2012
Posts: 86
Jeff Verdegan wrote:Not possible.

What is a world of ifs and elses if an if can be an else? Such a world would be decidedly metrosexual. Everything would be 'OK' but for some reason nothing would really work any more.

Maybe Java8 will have a "You're OK and I'm OK" feature and really screw things up. Can you imagine backward compatibility issues?

Have you checked out Aspose?
subject: Hello World!
It's not a secret anymore!