首页 > 编程知识 正文

long强制转换为int,字符串转long类型

时间:2023-05-05 10:13:09 阅读:49729 作者:2291

一.强制类型转换

长龙=300000; int i=(int ) long;

二、intValue (方法intI=newlong ) 30000 ).intValue );

三、将长整型转换为字符串字符串,然后跳槽到整型

长龙=300000;

inti=integer.parseint (string.value of (ll ) );

结果显示,使用queryrunner.query(connection,sql,new ScalarHandler ),args )返回int型数据时,long型建议以第3种方式迁移到int型

publicintegerselectcartscalercount (int userid ) stringSQL='selectsum ) count ) from t_cart where userId=? inti=integer.parseint (string.value of ) queryforscalar (SQL,userId ) ); 返回I; } publicobjectqueryforscalar (string SQL,Object.args )连接连接=JDBC utils.getconnection ); try { returnqueryrunner.query (连接,sql,新标量处理器),args ); }catch(exceptione ) { e.printStackTrace ); thrownewruntimeexception(e; }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。