Why do we need wrapper classes ?


It is sometimes easier to deal with primitives as objects. Moreover most of the collection classes store objects and not primitive data types. And also the wrapper classes provide many utility methods also. Because of these resons we need wrapper classes. And since we create instances of these classes we can store them in any of the collection classes and pass them around as a collection. Also we can pass them around as method parameters where a method expects an object.



Explore posts in the same categories: Java Interview Questions


BOOKMARK THIS : del.icio.us | Digg it | Furl | reddit |


Related Questions :

  • What are wrapper classes?
  • Wrapper classes are classes that allow primitive types to be accessed as objects....
  • What is Com Callable wrapper?when it will created?
  • .NET components are accessed from COM via a COM Callable Wrapper (CCW). This is similar to a RCW, but works...
  • What is Runtime Callable wrapper?.when it will created?.
  • The common language runtime exposes COM objects through a proxy called the runtime callable wrapper (RCW). Although the RCW appears...
  • Can the primary key in the entity bean be a Java primitive type such as int?
  • The primary key can't be a primitive type--use the primitive wrapper classes, instead. For example, you can use java.lang.Integer as...
  • What is an interface class?
  • Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They...
  • What are different types of inner classes?
  • Nested top-level classes, Member classes, Local classes, Anonymous classes Nested top-level classes- If you declare a class within a class and...
  • What are different types of inner classes?
  • Nested top-level classes, Member classes, Local classes, Anonymous classes Nested top-level classes- If you declare a class within a class and...
  • What is a Java package and how is it used?
  • A Java package is a naming context for classes and interfaces. A package is used to create a separate name...
  • How can I prevent the word “null” from appearing in my HTML input text fields when I populate them with a resultset that has null values ?
  • You could make a simple wrapper function, like then use it inside your JSP form, like " >...
  • How can I prevent the word “null” from appearing in my HTML input text fields when I populate them with a resultset that has null values
  • You could make a simple wrapper function, like then use it inside your JSP form, like " >...

    Comments are closed.