Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
Wrapper Classes 
 

In this section you will learn about Wrapper classes and all the methods that manipulate data and allows to operate a certain work.

 

Wrapper Classes

                         

 In this section you will learn about Wrapper classes and all the methods that manipulate data and allows to operate a certain work.

Wrapper class is a wrapper around a primitive data type. It represents primitive data types in their corresponding class instances e.g. a boolean data type can be represented as a Boolean class instance.
All of the primitive wrapper classes in Java are immutable i.e. once assigned a value to a wrapper class instance cannot be changed further.

Wrapper Classes are used broadly with Collection classes in the java.util package and with the classes in the java.lang.reflect reflection package.

Following table lists the primitive types and the corresponding wrapper classes:

Primitive Wrapper
boolean   java.lang.Boolean
byte   java.lang.Byte
char   java.lang.Character
double   java.lang.Double
float   java.lang.Float
int   java.lang.Integer
long   java.lang.Long
short   java.lang.Short
void   java.lang.Void
 

In Java 5.0 version, additional wrapper classes were introduced in the java.util.concurrent.atomic package. They provide atomic operations for assignment, addition and increment. These classes act like variables  and cannot be used as a substitute for the regular wrapper classes. Few of these new wrapper classes like AtomicInteger and AtomicLong are the subclasses of the Number Classes.

Primitive Wrapper
boolean   AtomicBoolean
int   AtomicInteger
long   AtomicLong
V   AtomicReference<V>

Features Of the Wrapper Classes

Some of the sound features maintained by the Wrapper Classes are as under :

  • All the methods of the wrapper classes are static.
  • The Wrapper class does not contain constructors.
  • Once a value is assigned to a wrapper class instance it can not be changed, anymore.

Wrapper Classes : Methods with examples

There are some of the methods of the Wrapper class which are used to manipulate the data. Few of them are given below:

1.    add(int, Object): Learn to insert an element at the specified position.

2.    add(Object): Learn to insert an object at the end of a list.

3.    addAll(ArrayList): Learn to insert an array list of objects to another list.

4.    get(): Learn to retrieve the elements contained with in an ArrayList object.

5.    Integer.toBinaryString(): Learn to convert the Integer type object to a String object.

6.    size(): Learn to get the dynamic capacity of a list.

7.    remove(): Learn to remove an element from a particular position specified by a  index value.

8.    set(int, Object): Learn to replace an element at the position specified by a  index value.

                         

» View all related tutorials
Related Tags: c ide array class list object insert io objects method vi arraylist dal using this id ai usage create example

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

It is very helpful but provide some examples along with expalnation

Posted by Vasu on Wednesday, 04.30.08 @ 10:52am | #58191

Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.