|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Be careful here, because the length of the string is dependent upon the number of blanks. Also, a 2 blank string is different from a 1 blank string. If your checking the length looking for an empty string, always use trim(). If using equal, the strings are not equal if the lengths are different, even if one just has spaces appended. Bill Brosch Swift Technologies e-mail: bbrosch@stecnet.com web site: http://www.stecnet.com phone: 1-847-289-8339 fax: 1-847-289-8939 - -----Original Message----- From: Timothy Sullivan [mailto:TSullivan@computer-guidance.com] Sent: Thursday, June 22, 2000 04:44 PM To: JAVA400-L@midrange.com Subject: RE: compare to a blank Hello, You may also want to consider the following since it is just as readable and _faster_ than the equals() method. With length(), you won't make a hard to see mistake like using " " instead of "". These bugs can be very hard to see in some editors and on printouts. Also, it will in help get rid of some of those oops "I used '==' instead of the equals()" bug. if (field.length() == 0) { } else { } - -or- if (field.trim().length() == 0) { } else { } /Tim -----BEGIN PGP SIGNATURE----- Version: PGP Personal Privacy 6.5.3 iQA/AwUBOVNXD0tp0tVY9BfCEQIcRwCgixaoAuTpPK6vA007M7NGqG8pOyUAoJ3g 5x7durnVKJ2DyDmT4MZ9XwhQ =CbBc -----END PGP SIGNATURE----- +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.