Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Beginner problem  RSS feed

 
Ryan Gabriel
Greenhorn
Posts: 20
Android Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I got a problem set from my teacher this morning. The task is to figure out the little mistakes in the code he also said there is more coming. And I know its super easy for some of you but not for me. My main concern here is else if statement.

I want to know/ learn about else if specifically any ideas? Books, chapter, Tutorials anything...
 
Brayn Richard
Greenhorn
Posts: 14
Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How much do you need?
There are a lot of tutorials about else if.
Try these-
This the old is gold
The new gold
and if you are looking for texts go for this and http://www.c4learn.com/java/java-if-statement/
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ryan Gabriel wrote:I want to know/ learn about else if specifically any ideas? Books, chapter, Tutorials anything...

Well, here's the link to the tutorials, which I got by Googling "java tutorials if statement". Just look for anything that starts with docs.oracle.com/javase/tutorial...

However "else if" is just a bit of syntactic sugar that allows you to writerather than:The two constructs are basically identical; the "else if" just saves you a pile of indentation.

Winston
 
Campbell Ritchie
Marshal
Posts: 55711
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What errors have you found? Do you mean compiler errors, poor design of the class, or what? Poor style? Tell us how many errors you have found.

There is no such thing as an else if stattement. What you have is an if embedded in the second part of an if‑else. If your first condition is not fulfilled, control goes to the else, and is immediately confronted with another test and another if. Start with the Java™ Tutorials. You cannot see it the way you write else if on one line. Everybody uses the one line technique, but this shows the actual structure of the if‑elses in that methodYou will probably never see a block of if‑else‑elses written like that again. But note the levels of indentation (which you don't usually write) and that shows how the ifs are embedded inelses.

If you have 90+ it is an A+ otherwise if you have 80+ it is an A otherwise if you have 70+ is it a B+ otherwise...
 
Campbell Ritchie
Marshal
Posts: 55711
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That c4learn tutorial is not at all good, I am afraid.
 
Steven Holtzer
Greenhorn
Posts: 2
Java Oracle Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not going to list the specific errors, but I found 9 mistakes in the code. As Winston already posted, the Oracle Java tutorials is a good place to start.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!