This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Else giving me error in class  RSS feed

 
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.

 
Author and ninkuma
Marshal
Posts: 66806
168
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.
 
Ranch Hand
Posts: 1156
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: 66806
168
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: 66806
168
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: 1156
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: 66806
168
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.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!