Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

objec to int

Status
Not open for further replies.

ttea

IS-IT--Management
Feb 24, 2003
11
HK
testing code:
...
ResultSet rs2 = stat.executeQuery(sql2);
if (rs2 != null) {
while (rs2.next()) {
String strcount = rs2.getString("count");
count.push(strcount);
} }
Object[] arrcount=count.toArray();

for(int i=0; i<arrcount.length; i++)
if ( start >= ((Integer)(arrcount)).intValue()))
....
I would to convert the object to int for calculation, but there is error, java.lang.String.
How can i do that? Thanks.


 
first don't use 'i' as an array subscript when posting in Tek-tips. It creates a TGML element when you post myarray[ i ]

>> if ( start >= ((Integer)(arrcount[n])).intValue()))

Code:
if( start >= Integer.parseInt(arrcount[n]) )

-pete
 
thanks, but i tried and found error:

for(int n=0; n<arrid.length; n++)
out.print(Integer.parseInt(arrcount[n]));

error:
cannot resolve symbol
symbol : method parseInt (java.lang.Object)
location: class java.lang.Integer


 
>>out.print(Integer.parseInt(arrcount[n]));

sorry

Code:
out.print(Integer.parseInt((String)arrcount[n])));
-pete

 
ic, it's ok now.

Thanks~:p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top