File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Java wrapper classses Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java wrapper classses" Watch "Java wrapper classses" New topic
Author

Java wrapper classses

Mark Mokris
Ranch Hand

Joined: May 08, 2002
Posts: 61
Each of the Java numeric wrapper classes seem to have two constants: NEGATIVE_INFINITY and POSITIVE_INFINITY. What do these mean, and what are they for? How might they be used?
Another question. I can see how the wrapper classes can be used to convert among numbers, strings, and primitive data values. Is there any other real use for them?
Thanks,
Mark
Jon Strayer
Ranch Hand

Joined: Dec 04, 2002
Posts: 133
Originally posted by Mark Mokris:
Each of the Java numeric wrapper classes seem to have two constants: NEGATIVE_INFINITY and POSITIVE_INFINITY. What do these mean, and what are they for? How might they be used?

Floating point math is a bit different from interger math. If you divide by zero using integer math you get an exception. If you divide by zero with floating point values you get an infinity back. You need to be able to test your answer to see if you hosed it up. That's what the constants POSITIVE_INFINITY and NEGATIVE_INFINITY are for. NaN stands for Not a Number. That's what you get when you try to take the square root of a negative number (for example).

Another question. I can see how the wrapper classes can be used to convert among numbers, strings, and primitive data values. Is there any other real use for them?
Thanks,
Mark

You can also put them into a container. You can't do that with the primitives.


Jon
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2853
    
  11

Right, what Jon said. The main use of wrapper classes is to use primitives where objects are required, like as elements of a Vector, ArrayList, or any of the collections.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java wrapper classses