LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 05-10-2006, 05:22 AM   #1
amolgupta
Member
 
Registered: Feb 2005
Location: agra,india
Distribution: FC2
Posts: 157

Rep: Reputation: 30
can some one explain me this java boolean expression


(o==null ? e==null : o.equals(e))

o is object.
i need to know thi to undersand collection.contains(object )

here is the link http://java.sun.com/j2se/1.4.2/docs/...a.lang.Object)
 
Old 05-10-2006, 05:51 AM   #2
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 46
They mean if "o" and "e" are either both null or are "equal". It's essentially saying "o.equals(e)", except they account for the technicality that if "o" was null then obviously you can't call the ".equals()" method, but for our purposes we still want null references to be considered equal to each other.

Last edited by spooon; 05-10-2006 at 05:57 AM.
 
Old 05-10-2006, 11:10 AM   #3
Vagrant
Member
 
Registered: Nov 2001
Posts: 75

Rep: Reputation: 15
Look up the ternary operator.
 
Old 05-11-2006, 02:46 AM   #4
amolgupta
Member
 
Registered: Feb 2005
Location: agra,india
Distribution: FC2
Posts: 157

Original Poster
Rep: Reputation: 30
how can i override them the .equals() function in a subclass of object
 
Old 05-11-2006, 04:54 AM   #5
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 46
Quote:
Originally Posted by amolgupta
how can i override them the .equals() function in a subclass of object
Just define a method in your class like this:
Code:
public boolean equals(Object obj) {
// blah blah blah
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rular expression matching with java linuxmandrake Programming 2 04-13-2006 11:35 AM
Frustrating self resetting boolean in java linuxmandrake Programming 2 04-11-2006 08:05 PM
java setOpaque(boolean) nocturna_gr Programming 1 03-13-2006 05:14 PM
boolean question! xemous General 3 03-18-2005 03:40 AM
align columns of strings and explain '\t' (java) dave bean Programming 3 01-10-2004 10:55 PM


All times are GMT -5. The time now is 03:15 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration