File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Integer class

 
Nazma Panjwani
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If you instantiate the Integer class passing in a certain value such as 60...is it possible to change that value to something else later on?
Thanks
 
Rob Spoor
Sheriff
Pie
Posts: 20398
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The object itself can never change anymore. You cannot modify any of its fields, nor call any method that changes it. You can still change the value the reference points to. For instance:
 
Marcos Stoppa
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At Java 5, was added the called autoboxing. With autoboxing you can create a new Wrapper object, with a new value, without manually boxing and unboxing it.

 
Rob Spoor
Sheriff
Pie
Posts: 20398
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know, but I set up my Eclipse to warn against it. Autoboxing is not a problem, but autounboxing is a potential NullPointerException waiting to happen if you're not careful. Because you're not dereferencing anything yourself it will be harder to find the culprit.
 
Nazma Panjwani
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marcos Stoppa wrote:At Java 5, was added the called autoboxing. With autoboxing you can create a new Wrapper object, with a new value, without manually boxing and unboxing it.



Hey,

It doesn't work, since i is already defined......
 
Marcos Stoppa
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oooops, sorry. My fault.

The correct is:
Thanks Nazma!

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic