my dog learned polymorphism*
The moose likes IDEs, Version Control and other tools and the fly likes If then else statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "If then else statement " Watch "If then else statement " New topic
Author

If then else statement

Ola Olusegun
Greenhorn

Joined: Jun 13, 2013
Posts: 15
Hello,
I am beginning to enjoy writing noob codes in java, but i am kinda lost here. please check the code below and tell me why the 2nd else if part is not displaying hurray you are welcome. it's always going to the else part. i feel i have met the conditions for it to display the hurray part.please advise me on what to do.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41083
    
  43
With a value of 48 for toyin, do you really think either of the if conditions in lines 12 or 15 should be satisfied?


Ping & DNS - my free Android networking tools app
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4342
    
    7

I just ran that code, and I got the output "hurray you are welcome". Are you sure the code you are running is the code you just posted?

A couple of things about your if statements, though:

- (toyin <= 18 && toyin == 18) is just the same as (toyin == 18). If the second part is true the first must be.

- (toyin == 18 || toyin == 19) in this context is that same as (toyin == 19). If toyin is 18 then the execution would never reach that line because the first if condition would be true.
Ola Olusegun
Greenhorn

Joined: Jun 13, 2013
Posts: 15
@Mathew Brown, If it returned hurray after you ran it, then i must have been right, but the netbeans ide is not showing that . Why is my IDE returning the else statements below ?
Ola Olusegun
Greenhorn

Joined: Jun 13, 2013
Posts: 15
Hello,
When i used notepad++ to write the same code, I compiled it in command prompt and got the following error message.I wonder why it is running in Net beans . The error message. Exception in thread "main" java.lang.NoClassDefFoundError ifThenElse <wrong name: ifThenElse/ifThenElse> .It had some package extensions below.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

Regarding your Notepad++ question, I saw your other post first and answered it there, please do not ask the same question in multiple posts. I'll leave this post open because I think you are still asking questions related to your original question.


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: If then else statement
 
Similar Threads
What does it mean by final method arguments or final local variables in a instance method ?
Spotting errors
Unable to Access mysql database through JNDI.
How?
Library System