Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-04-2008, 11:42 AM
Member
 
Join Date: Jul 2007
Posts: 4
thirdy_veritech is on a distinguished road
Comparing null problem
Hi, I have a problem with comparing Big Decimal with null
Code:
for (int x = 0; x < engagementList.size(); x++) { if(engagementList.get(x).getOverall_aef() != null) engagementList.remove(x); } for(int a = 0; a < engagementList.size(); a++){ log.info("engagementList.get(a).getOverall_aef()="+engagementList.get(a).getOverall_aef()); }
Output:
Code:
INFO 2008-02-04 17:39:06,828 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null INFO 2008-02-04 17:39:06,828 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null INFO 2008-02-04 17:39:06,828 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null INFO 2008-02-04 17:39:06,843 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null INFO 2008-02-04 17:39:06,843 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null INFO 2008-02-04 17:39:06,843 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=57.50 INFO 2008-02-04 17:39:06,843 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null INFO 2008-02-04 17:39:06,843 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null INFO 2008-02-04 17:39:06,843 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null INFO 2008-02-04 17:39:06,843 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null INFO 2008-02-04 17:39:06,843 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null INFO 2008-02-04 17:39:06,859 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null INFO 2008-02-04 17:39:06,859 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null INFO 2008-02-04 17:39:06,859 [EngagementAction.java:2989] engagementList.get(a).getOverall_aef()=null
an object with "Overall_aef" of 57.50 was not removed. Is it bad to compare with null? Is there any alternative?
Thanx!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-05-2008, 08:42 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,146
hardwired is on a distinguished road
engagementList.get(x).getOverall_aef()
Does this method return a BigDecimal?
These work okay:
Code:
BigDecimal one = BigDecimal.ONE; System.out.println("one = " + one); System.out.printf("one == null = %b%n", one == null); System.out.printf("one.equals(null) = %b%n", one.equals(null));
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-06-2008, 09:46 AM
Member
 
Join Date: Jul 2007
Posts: 4
thirdy_veritech is on a distinguished road
Quote:
Originally Posted by hardwired View Post
engagementList.get(x).getOverall_aef()
Does this method return a BigDecimal?
Yes it returns a Big Decimal. How come my loop doesn't remove all Object(named Engagement) in my List(engagementList) with !null BigDecimal overall_aef?

I've already solve my problem by search the database rather than filtering the List but I'm still mystified why my loop didn't work well.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem comparing three numbers gammaman New To Java 1 02-09-2008 06:43 PM
Comparing problem mcal New To Java 1 01-24-2008 04:56 AM
comparing Feng New To Java 2 11-23-2007 10:40 AM
Problem with JTextFields not null romina AWT / Swing 1 08-07-2007 06:17 AM
Comparing types, integer with null Felissa New To Java 1 07-05-2007 07:32 AM


All times are GMT +3. The time now is 12:33 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org