File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes small doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "small doubt" Watch "small doubt" New topic

small doubt

vivek gaur

Joined: Dec 30, 2005
Posts: 21
1) what does 'instanceof' operator mean?
2) what actually happens if we remove static from main?
3) when do we use Wrapper classes and why?
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

1) instanceOf will tell you the type is an object is of any particular type.
For example :

means "if myCar is a Car class or subclass then"

2) try it yourself

3) Wrapper classes offer useful methods. Have a look at the Integer class. You can convert a number into hexadecimal, octal, binary, double, float....

[My Blog]
All roads lead to JavaRanch
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
3) Wrapper classes are often used when you need an Object but you have a primitive type instead. For example, you can "wrap" an int into an Integer in order to store it in a Collection.

Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: small doubt
It's not a secret anymore!