File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equals method

 
Smitha Ballikar
Ranch Hand
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Here it gives compiler error.I thought it would print "We are not Equal".
Cant we use null with equals method??
 
Rushikesh Wagh
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.equals() Method Is Used To Compare The Objects And null Is Not An Object. Hence It Has Compile Time Error. Please Do Correct Me If I m Wrong.
 
Ryan Kade
Ranch Hand
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rushikesh is correct, null is a literal, not an object. Trying to call a method on null would be like trying to call a method on the number 5 or the boolean value true.
 
raghu babu
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on the same lines, try this :

Byte b2 = new Byte("11");

if(b2.toString() == b2.toString())
System.out.println("True");
else
System.out.println("False");
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic