• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

if / else problem

 
Supun Lakshan Dissanayake
Ranch Hand
Posts: 135
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to print "Hello World" (without quotes) as final output without editing if /else code blocks.
only you are allow to edit is condition of if statement.
How do i get that?
What is the statement that replaces /* edit this condition */ ?



Any ideas???

Thanks
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
executing both if and else is not possible as far i know. however regarding your result output...


 
Rohan Deshmkh
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In java the if condition must have a expression that results into a boolean value.But the closest i got to print hello world was using the foll code:

 
Supun Lakshan Dissanayake
Ranch Hand
Posts: 135
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote:executing both if and else is not possible as far i know.


Pretty sure there is a possible way to print Hello World without executing if code block.
I saw one of my friends did that using

or something like that.

anyway thanks for the post!
 
Campbell Ritchie
Sheriff
Pie
Posts: 49813
69
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh good grief! I hope you reserve code for showing to friends after you have had too much to drink. If you hand that in in real life, you can expect to have your job terminated PDQ!
 
Supun Lakshan Dissanayake
Ranch Hand
Posts: 135
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Oh good grief! I hope you reserve code for showing to friends after you have had too much to drink. If you hand that in in real life, you can expect to have your job terminated PDQ!


Eureka!!! finally found it.
Here is the code.



output is Hello World
anyway Thanks for the posts guys!
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Supun Lakshan Dissanayake wrote:
Campbell Ritchie wrote:Oh good grief! I hope you reserve code for showing to friends after you have had too much to drink. If you hand that in in real life, you can expect to have your job terminated PDQ!


Eureka!!! finally found it.
Here is the code.



output is Hello World
anyway Thanks for the posts guys!


I hope you realize that nobody would ever write real code like this, or if they did, they wouldn't keep their job for long. This kind of code should only be used to test in-depth knowledge or persnickety language details and ability to "think outside the box," and even then, the general opinion is divided about 50/50 on whether it's useful for taht purpose or just plain stupid and pointless.

Also, somebody (don't know if it was you) recently posted the same initial code and asked how to execute both the if block and the else block. Note that this code does not do that, and that it is impossible to do that.

 
Supun Lakshan Dissanayake
Ranch Hand
Posts: 135
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:
I hope you realize that nobody would ever write real code like this, or if they did, they wouldn't keep their job for long. This kind of code should only be used to test in-depth knowledge or persnickety language details and ability to "think outside the box," and even then, the general opinion is divided about 50/50 on whether it's useful for taht purpose or just plain stupid and pointless.

Also, somebody (don't know if it was you) recently posted the same initial code and asked how to execute both the if block and the else block. Note that this code does not do that, and that it is impossible to do that.



Thanks for the post.

I'm the topic starter and i'm the one who post the answer also.
I know if i use the output is Bye World.
All i needed was the condition for print hello world (it was a question of a paper).
I think by using is caused to break standards.

Dear Jeff Verdegan, I really appreciate your post for point it. THANK YOU AGAIN !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic