• Post Reply Bookmark Topic Watch Topic
  • New Topic

Else giving me error in class  RSS feed

 
David Ausere
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any see why my else command is giving me fits?  Giving me an error in class.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carefully review the placement of your semicolons. And never omit the braces around blocks.

And, in the future, always include the text of any error messages.
 
David Ausere
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just figured it out.  But a new problem work when I test it compiled.  When I type "YES" to delete the roster record it just skips to the else portion.
 
Ryan McGuire
Ranch Hand
Posts: 1143
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the new version of hte code look like?

(Edited my reply to be a bit less snide.)
 
David Ausere
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wise man.  So I thought I learned from the wise man, but apparently not.  A typed "YES" response will still not execute that way I am thinking it should..

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Review the manner in which Strings should be compared.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AND, never omit the braces around blocks.
 
Ryan McGuire
Ranch Hand
Posts: 1143
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google "java string equality"
 
David Ausere
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Figured that one out as well!
 
David Ausere
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ryan thank you for the pointer.  I got there.
So here is my code:  Can anyone see the problem with the logic?  I can and am trying to figure out  my way around it.  I have a thought which I will put at the end.


The problem with my logic is that once I delete the first record in the array, even though the ID remains 2,3,4,5 (and so on) if I try to delete another record after that it will not delete the right record because in the array list it will be 0,1,2,3 to 2,3,4,5.  So if I try and deleted id 2 record 4 will actually get deleted.

So my thinking is this.  Is there a way to repopulated the ID portion of the array again into numerical order thus changing the ID of all the students?  Or would there be a better way to do this?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:AND, never omit the braces around blocks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!