java中int,char,string三种类型的相互转换
如何将字串 String 转换成整数 int? int i = Integer.valueOf(my_str).intValue();
int i=Integer.parseInt(str);
如何将字串 String 转换成Integer ? Integer integer=Integer.valueOf(str);
如何将整数 int 转换成字串 String ? 1.) String s = String.valueOf(i);
2.) String s = Integer.toString(i);
3.) String s = "" + i;
如何将整数 int 转换成Integer ? Integer integer=new Integer(i);
如何将Integer 转换成字串 String ? Integer integer=String
如何将Integer 转换成 int ? int num=Integer.intValue();
如何将String转换成 BigDecimal ? BigDecimal d_id = new BigDecimal(str);
如何将 String 转换成 char ? char[] ca="123".toCharArray();
如何将char转换成String? String s=ca.toString(); //任何类型都可以采用toString()转换成String类型
另附对时间的处理:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); //按照2011-09-21 13:33:24:456的格式输出时间 sdf.format(new Date());
java中int,char,string三种类型的相互转换的更多相关文章
- [转] java中int,char,string三种类型的相互转换
原文地址:http://blog.csdn.net/lisa0220/article/details/6649707 如何将字串 String 转换成整数 int? int i = Integer.v ...
- C# enum、int、string三种类型互相转换
enum.int.string三种类型之间的互转 #代码: public enum Sex { Man=, Woman= } public static void enumConvert() { in ...
- 计算机基础--Java中int char byte的关系
计算机基础--Java中int char byte的关系 重要:一个汉字占用2byte,Java中用char(0-65535 Unicode16)型字符来存字(直接打印输出的话是字而非数字),当然要用 ...
- JAVA中int与String类型的相互转换
Java的int和String类型间互相转换,小功能但是经常用到,下面是几种实现的方法: 字符串类型String转换成整数int 1. int i = Integer.parseInt([String ...
- C++处理char*,char[],string三种类型间的转换
前言 在C和C++中,有一个相当重要的部分,就是字符串的编程描述.在学C的时候,很多人习惯了char[],char*表示法,直到遇见了C++后,出现了第三者:string.这时候,很多初学者就会在这三 ...
- JAVA中int转String类型有三种方法
String.valueOf(i) Integer.toString(i) i+"" i+""也就是一个int型的常量.+上个空的字符串,这里牵涉到了strin ...
- Java中int和String类型之间转换
int –> String int i=123; String s=""; 第一种方法:s=i+""; //会产生两个String对象 第二种方法:s=S ...
- JAVA中int转string及String.valueOf()的使用
日常java开放中,经常会遇到int和String的互转,一般图省事的做法就是: String length = ""+100; length的生成需要使用两个临时字符串" ...
- java中遍历集合的三种方式
第一种遍历集合的方式:将集合变为数组 package com.lw.List; import java.util.ArrayList; import java.util.List; import ja ...
随机推荐
- (step8.2.4)hdu 1846(Brave Game——巴什博奕)
题目大意:输入一个整数t,表示测试用例是.接着输入2个整数n,m.分别表示这堆石头中石头的个数,和每次所能取得最大的石头数.判断那一方为赢家 解题思路: 1)这是一道简单的巴什博弈: 所谓巴什博弈,是 ...
- Android Input设备debug技巧
一.驱动层 检查是否有点上报 adb shell getevent -l /dev/input/eventX 检查input设备支持的属性值 adb shell getevent -i /dev/in ...
- OpenWRT推理client线上的数
有两种方法: 一. 经DHCP client通讯组列表 (缺点:client列表会依据超时时间刷新,一般超时时间为12h,) 二. 通过arp缓存列表/proc/net/arp(缺点:arp刷新时间默 ...
- [Swust OJ 649]--NBA Finals(dp,后台略(hen)坑)
题目链接:http://acm.swust.edu.cn/problem/649/ Time limit(ms): 1000 Memory limit(kb): 65535 Consider two ...
- [Swust OJ 1026]--Egg pain's hzf
题目链接:http://acm.swust.edu.cn/problem/1026/ Time limit(ms): 3000 Memory limit(kb): 65535 hzf ...
- HTTP 教程 转自 http://www.w3cschool.cc/http/http-tutorial.html
HTTP协议(HyperText Transfer Protocol,超文本传输协议)是因特网上应用最为广泛的一种网络传输协议,所有的WWW文件都必须遵守这个标准. HTTP是一个基于TCP/IP通信 ...
- ubuntu学习: apt-get命令
1.apt-get update 更新软件源本地缓存文件 2.apt-cache search 查找软件包,找到想要安装的包,如 sudo apt-cache search mysql-server ...
- ios中的任务分段
工作比较忙,蛮久没有写东西了,今天我要写的是ios中的任务分段.大多数的情况下,我们用不到任务分段,但是如果我们是在执行比较频繁的函数或者这个函数是比较耗时, 某一条件下,我要执行新的任务,并且取消上 ...
- 基于visual Studio2013解决算法导论之024双向链表实现
题目 双向链表的实现 解决代码及点评 #include <stdio.h> #include <stdlib.h> #include <time.h> #i ...
- UVA 10020 Minimal coverage(贪心 + 区间覆盖问题)
Minimal coverage The Problem Given several segments of line (int the X axis) with coordinates [Li, ...