Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Usage of :- int comapareTo(float f)

 
Kapil Sachdeva
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can u please tell me the usage of int compareTo(float f) method defined in java.lang.Float. Please give some code lines.
 
Art Metzer
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To compare primitives, you can use less-than and greater-than signs.
To compare the values that the wrapper classes contain, you need to use compareTo().

returns:

HTH
Art
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I can give you the example show below.

The compareTo method is useful when dealing with extremes. That is POSITIVE_INFINITY, NEGATIVE_INFINITY, NAN, +/-0.0f.
Regards,
Manfred.
 
Kapil Sachdeva
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to both of u
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic