• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Comparing Wrapper Class Objects

 
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to do the following.



public class ComparingWrapperClasses {

Double d1 = new Double(3.1);
Double d2 = new Double(3.1);

if(d1.equals(d2))
{
System.out.println("True");
}

}



And there seems to be an error at the bolded part. Can someone please tell me what I am doing wrong? I am using Wsad btw.

Thanks.
[ June 05, 2008: Message edited by: Arjun Reddy ]
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "if" statement is *not* part of a method, initalizer, constructor, etc.

Henry
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Henry,

Um..So, how should I compare two wrapper class objects if they have the same value? Also, is there any way I can compare two StringBuffer objects too?

Thanks.


Oh okie.. sorry.. I am able to compare the wrapper class objects. I just have to put the if stmnt in a method and I did it. Sorry about that.
[ June 05, 2008: Message edited by: Arjun Reddy ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic