Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-13-2007, 11:18 AM
Member
 
Join Date: Dec 2007
Posts: 1
binoympappachen is on a distinguished road
problem in wrapper class
HI all,

Plz assist me to clear some doubt in wrapper class.

Actually wrapper class is used to convert primitive data types to object type.
For Eg:
Integer a=new Integer(10);
Now 'a' would be Integer object.
As far as my knowledge, object cannot go through any arithmetic operation directly .But when i gone through these steps in eclipse ide a++ worked perfectly.How it would be possible.Hope some one will clariffy this doubts,

All comments regarding this tipic is highly appreciated.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-13-2007, 11:38 AM
Senior Member
 
Join Date: Nov 2007
Location: Newport, WA
Posts: 141
staykovmarin is on a distinguished road
There is only one class that can undergo arithmetic operation, and that is the String class. It can only add two Strings together, which is called concatenation , when you add them together. The Inter class just allows for certain operations that PRIMITIVES cannot do:

Integer a, b;
assuming they have been assigned values:
a + b will NOT work

On the other hand

int a, b;
a + b WILL work because int is a primitive

I suggest that you use the Integer, Double, Float, and so on classes, only when you need some of the methods they provide.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-13-2007, 11:45 AM
Member
 
Join Date: Dec 2007
Posts: 11
gulapala is on a distinguished road
Hi binoympappachen,

First let me know which version of Java you are using. Because in jdk1.4 you can;t do arithmetic operation over Integer objects. But from Java 5, because of the concepts of boxing and unboxing, Integer,Double Objects can also do arithemetic operations, as the JVM internally

1. converts the objects to primitive values
2. Does the arithmetic operation
3. Converts the result to an Object datatype.
__________________
Thanks & Regards, G.Rajasekhar
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-13-2007, 12:01 PM
Senior Member
 
Join Date: Nov 2007
Location: Newport, WA
Posts: 141
staykovmarin is on a distinguished road
Eh, i was completely wrong in my previous post... i guess there are downsides to switching over the 5 very late :\.

Anyways, sorry for a misleading post, dont listen to me
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 12-13-2007, 01:31 PM
Member
 
Join Date: Dec 2007
Posts: 11
gulapala is on a distinguished road
I don't think there are any downsides in switching to 5.0. By switching you can also use new feature that are been introduced in Java 5.0
__________________
Thanks & Regards, G.Rajasekhar
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Service Wrapper 3.3.0 Java Tip Java Announcements 0 03-29-2008 02:04 PM
wrapper classes sireesha New To Java 5 12-11-2007 10:45 PM
javax.servlet.ServletException: Wrapper cannot find servlet class util.t2 osval Advanced Java 1 08-07-2007 04:47 PM
Exception Failed to Generate Wrapper Class on WebLogic christina New To Java 1 08-07-2007 03:15 AM
Java Wrapper Classes JavaForums Java Blogs 0 08-04-2007 03:24 AM


All times are GMT +3. The time now is 07:53 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org