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 09-28-2007, 01:28 PM
Member
 
Join Date: Aug 2007
Posts: 13
Bojevnik is on a distinguished road
How to use <,>,== on custom classes
Is it possible to use <>= on custom class?
for example
Code:
... CustomClass a = new CustomClass(x); CustomClass b = new CustomClass(y); if(a<b)...
I already played with comparable and comparator interface but with no luck.
__________________
I HATE SMURFS!!!!!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-28-2007, 01:35 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
I did not see such a thing. What is the meaning of the operation in your mind? I mean, you can compare two integers but what can be the meaning of comparison of two classes?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 09-28-2007, 03:00 PM
Member
 
Join Date: Aug 2007
Posts: 13
Bojevnik is on a distinguished road
You would define the meaning of comparison.
Because that's what i thought comparabele does.

if you would call let's say a==b, progrgam would automaticly called function
compareTO and if result would be 0, the statement would be true otherwise it would be false.

EDIT: Thanks for answert, but i've heard it can't be done.
__________________
I HATE SMURFS!!!!!

Last edited by Bojevnik : 09-28-2007 at 03:25 PM. Reason: new info
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 10-01-2007, 09:54 AM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
As far as i know, that is called operator overloading in C++ and Java does not have that. But of course instead of operator overloading, you can define your comparison with Comparable interface.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 10-29-2007, 06:00 PM
Member
 
Join Date: Oct 2007
Posts: 2
remnahush is on a distinguished road
You must implement the Comparator interface at the class
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
Custom Avatar JavaBean Suggestions & Feedback 4 01-17-2008 01:28 AM
RCP Custom Look and Feel JavaForums Java Blogs 0 01-02-2008 07:12 PM
Custom tgs in JSP ravian New To Java 2 12-29-2007 06:05 PM
What are Custom Scopes in SpringFramework JavaBean Java Tips 0 09-28-2007 01:48 PM
Help with custom component Falcon1 AWT / Swing 8 07-21-2007 01:39 PM


All times are GMT +3. The time now is 04:45 AM.


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