File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 1545

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?

I agree. Here's the link:
subject: Hello World!
jQuery in Action, 3rd edition