• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

again and again WRAPPER

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers !

Interger a = new Integer ("10");

a = a + 20 ; //can we do this by any means of explicit / implicit casting


if no then can i assume that we wrapping up the a = 10 as an object we are creating something similar to FINAL.


Thank you friends

Chintan Ramavat
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried to compile it? Does it work?

Hint: Make sure you try it with Java 5 or greater.

Henry
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you can do that starting with JDK 5.0. It is called autoboxing and autounboxing.

Wrapper objects are immutable.
 
chintan ramavat
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Henry

no i am getting CASTING ERROR. I am running eclipse with latest JRE.
what do you think about this doubt ?

can we change Wrapper Class object or its just mean for single assignment. iam bit confused here.


Thanks
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by chintan ramavat:
no i am getting CASTING ERROR. I am running eclipse with latest JRE.
what do you think about this doubt ?

can we change Wrapper Class object or its just mean for single assignment. iam bit confused here.



First, confirm that you have installed and running a JRE, that is at least 5.0... Window --> Preferences --> Java --> Installed JRE --> get the path and check it.

Second, confirm that you have the compliance level set to at least Java 5.0... Window --> Preference --> Java --> Compiler --> compliant level. Also check the source and class file compatibility.


BTW, with my Java 5.0 JDK, it compiles fine. And the Integer "a" ends up with a value of 30.

Henry
[ February 20, 2007: Message edited by: Henry Wong ]
reply
    Bookmark Topic Watch Topic
  • New Topic