首 页 网络编程
网页制作 图形图象 操作系统 冲浪宝典
软件教学 认证考试

网络安全 网络办公 行业资讯 评测对比
您当前位置:站长天空 -> 网络编程-> Perl教程
简要JAVA数据类型转换-JSP教程,Java技巧及代码
作者:网友供稿 点击:281
推荐
西部数码-全国虚拟主机10强!20余项虚拟主机管理功能,全国领先!第6代双线路虚拟主机,南北访问畅通无阻!可在线rar解压,自动数据恢复设置虚拟目录等.免费赠送访问统计,企业邮局.Cn域名注册10元/年,自助建站480元起,免费试用7天,满意再付款!P4主机租用799元/月.月付免压金
站内搜索
文章页数:[1] 
1如何将字串 string 转换成整数 int?

a. 有两个方法:

1). int i = integer.parseint([string]); 或
i = integer.parseint([string],[int radix]);

2). int i = integer.valueof(my_str).intvalue();

注: 字串转成 double, float, long 的方法大同小异.


2 如何将整数 int 转换成字串 string ?


a. 有叁种方法:

1.) string s = string.valueof(i);

2.) string s = integer.tostring(i);

3.) string s = "" + i;

注: double, float, long 转成字串的方法大同小异.



java数据类型转换 ynniebo [收藏]
关键字 类型转换
出处

这是一个例子,说的是java中数据数型的转换.供大家学习引

package cn.com.lwkj.erts.register;
import java.sql.date;
public class typechange {
public typechange() {
}
//change the string type to the int type
public static int stringtoint(string intstr)
{
integer integer;
integer = integer.valueof(intstr);
return integer.intvalue();
}
//change int type to the string type
public static string inttostring(int value)
{
integer integer = new integer(value);
return integer.tostring();
}
//change the string type to the float type
public static float stringtofloat(string floatstr)
{
float floatee;
floatee = float.valueof(floatstr);
return floatee.floatvalue();
}
//change the float type to the string type
public static string floattostring(float value)
{
float floatee = new float(value);
return floatee.tostring();
}
//change the string type to the sqldate type
public static java.sql.date stringtodate(string datestr)
{
return java.sql.date.valueof(datestr);
}
//change the sqldate type to the string type
public static string datetostring(java.sql.date datee)
{
return datee.tostring();
}

public static void main(string[] args)
{
java.sql.date day ;
day = typechange.stringtodate("2003-11-3");
string strday = typechange.datetostring(day);
system.out.println(strday);
}


}


java中常用数据类型转换函数
虽然都能在java api中找到,整理一下做个备份。

string->byte
byte static byte parsebyte(string s)

byte->string
byte static string tostring(byte b)

char->string
character static string to string (char c)

string->short
short static short parseshort(string s)

short->string
short static string tostring(short s)

string->integer
integer static int parseint(string s)

integer->string
integer static string tostring(int i)

string->long
long static long parselong(string s)

long->string
long static string tostring(long i)

string->float
float static float parsefloat(string s)

float->string
float static string tostring(float f)

string->double
double static double parsedouble(string s)

double->string
double static string tostring(double

文章整理:站长天空 网址:http://www.z6688.com/
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

文章页数:[1] 


放大字体显示 缩小字体显示 打印文章 推荐给朋友
热门文章
·无刷新聊天室(短信陪聊程序)-ASP教程,ASP应用
·C#中使用Excel-.NET教程,C#语言
·简要JAVA数据类型转换-JSP教程,Java技巧及代码
·Recordset对象方法详解-ASP教程,ASP应用
·选用和配置ups时应注意的几个问题
·新型无源元件的现状与发展
·用正则表达式解析C#文件(updated)-.NET教程,C#语言
·正则表达式大全-ASP教程,ASP应用
·VB与ActiveX控件签名谈-.NET教程,VB.Net语言
·IIS6 和Tomcat5 的整合-ASP教程,ASP应用
最新文章
·网上能免费赚钱?想要网上创业吗?_网赚技巧
·孙中伟:聚合文学网站资源的功能_站长访谈
·网站最令人讨厌的用户体验_站长心得
·设计理论:谈用户体验,别落下商业利益_站长心得
·经营个人网站需要脚踏实地_站长心得
·google adwords关键词广告须注意的7个问题_google推广
·网站提交google注册应注意的问题_google推广
·伦敦mecompany网站设计师谈网页布局艺术2_站长心得
·搜索引擎不收录页面的常见原因_seo网站优化
·搜索引擎注册九大秘法_站长心得
相关主题
西部数码虚拟主机

友情链接
CNNIC 西部数码
万网 自助建站
虚拟主机 asp空间
域名注册 域名
域名申请 主页空间
论坛空间 网站空间
国际域名 虚拟空间
空间租用 DDOS防火墙
成都主机托管 四川主机托管
主机租用 服务器租用
网站目录 自助建站
虚拟主机 网址大全
软件下载
自助链接
虚拟主机资讯 特价虚拟主机
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
关于我们:站长天空:专业提供最新的站长资讯、在线教程、虚拟主机权威评测、虚拟主机性能对比、网站制作教程,开发教程,站长工具。包括网页制作教程、冲浪宝典、编程参考、操作系统、软件教学、行业动态等。
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
发表评论 打印  刷新     关闭