• 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:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Assert syntax

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I keep getting AssertionError on this statement, is there a way to do this?



Pardon my ignorance, as this is my first foray into assertions.

Any help appreciated!

Thanks
bw

 
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Asserts can be disabled so you should do the assert like this:



I am not an assert expert so try it and let me know
 
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using the -enableassertion or -ea command line options when running your code?

John.
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, the AssertionError is getting thrown because your getFName() is returning an empty String.
 
B West
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for your replies. I got it figured out. The assert statement was fine. I had something up stream that was cause my assert to be triggered.. So HA, score one for the debugging merits of assert!!

Thanks again to all that replied!
bw
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's exactly what asserts are for, glad it worked

While I'm here B... you should probably change your name before a mod gets to you. Your user name must be a full name, unless your first name is really the letter B!
 
Sheriff
Posts: 21775
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, initials are allowed as the first name. It's the last name that can't be an initial.
 
Marshal
Posts: 65113
247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect your problem is caused by using == or != for object equality; you ought to use the equals() method.
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you really want to get techinical you are missing a ')' on the if statement

Thanks Rob for clearing that up
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!