java - What isn't comparable by the Comparable class? -


I know that this class compares two objects in a class (for example two strings), but its use How are the comparisons not class?

Basically, you can compare everything in Java.

For example, you have a class X , which is incomparable, you can create this attribute on another class C and < Code> C , it can override its compare () method.

For example, it does not make sense to compare the colors

This is correct though it does not make sense, you can Are there. Here is the answer to the question:

Which color is bright?

  Public class ComparableColor implements Comparable & lt; ComparableColor & gt; {Color color; Public Comparison Color (Color Color) {this.color = color; } Compare @ Override Public Int (Comparative Caller C) {return c.color.getAlpha () - this.color.getAlpha (); }}    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -