How to add a value in Integer object An eg: Integer no = new Integer(); no = no+1; It throws an error why we have to convert in to primitive type int and add it. Regards, aakash
The Integer constructor takes a parameter, either an int or a String. The parameter specifies the Integer's initial value. You can't add one to a number until you know what that number is. [ July 11, 2002: Message edited by: Elouise Kivineva ]
Yes I missed the parameter The statement Integer t = new Integer(2); t = t+1; Throws an error operator + cannot be applied to java.lang.Integer,int Regards, aakash
An Integer object, like other wrapper objects, is immutable. Once it is created, its state cannot be changed. You will just have to create a new Integer object.