Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 42
Registered: ‎05-17-2011
My Device: all
My Carrier: all
Accepted Solution

initialising a blank integer in persistent storage

Hi - can someone put me out of my misery with this little one please. Using v 5 of the SDK. All I want to do is create a blank new integer in a peristent storage object for use at a later date (like creating an empty string). So this code fails but I don't know how to get around it:

 

persistentHashtable.put("Test", new Integer());

 

error message says Integer(int) in java.lang.Integer cannot be applied to () so presumably you can't initalise this without specifying a value. I don't want this initialised with a value of 0 because thats a value - all I want is an empty integer. Quotes doesn't work, null doesn't work - help pls?

Developer
Posts: 17,019
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: initialising a blank integer in persistent storage

An Integer object cannot exist without a value.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: initializing a blank integer in persistent storage

There is no 'undefined' value for the Integer object as you have found.

 

The two options that immediately spring to mind are:

a) Create an extended Integer that supports a 'blank' setting

b) Use null to indicate this.

 

(b) means not having a value in the Hashtable - so the lack of value indicates a blank Integer. 

Contributor
Posts: 42
Registered: ‎05-17-2011
My Device: all
My Carrier: all

Re: initialising a blank integer in persistent storage

thanks guys