aspose file tools*
The moose likes Beginning Java and the fly likes Assert syntax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Assert syntax " Watch "Assert syntax " New topic
Author

Assert syntax

B West
Greenhorn

Joined: Oct 10, 2008
Posts: 29
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

Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
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


SCJA
~Currently preparing for SCJP6
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Are you using the -enableassertion or -ea command line options when running your code?

John.
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
By the way, the AssertionError is getting thrown because your getFName() is returning an empty String.
B West
Greenhorn

Joined: Oct 10, 2008
Posts: 29
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

Joined: Nov 07, 2008
Posts: 488
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!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

Actually, initials are allowed as the first name. It's the last name that can't be an initial.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
I suspect your problem is caused by using == or != for object equality; you ought to use the equals() method.
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
Well, if you really want to get techinical you are missing a ')' on the if statement

Thanks Rob for clearing that up
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assert syntax