int 转 String:

 //方式一:
int i1 = 888;
String s1 = Integer.toString(i1); //方式二:
int i2 = 888;
String s2 = String.valueOf(i2); //方式三:
int i3 = 888;
String s3 = i3+"";

String 转 int :

 //方式一:
String s = "888“;
int i = Integer.parseInt(s); //方式二:
int i1 = Integer.valueOf(s);

int 转 char:

 int in1 = 5;
//强转
char ch1 = (char)(in1+48);

char 转 int:

 Character c = '5';
//方法一:调用包装类parseInt方法
int in2 = Integer.parseInt(c.toString()); char ch2 = '5';
//方法二:用unicode编码
int in3 = ch2-48;

八种基本包装类:

  byte :java.lang.Byte
      short :java.lang.Short
      int: java.lang.Integer
      long :java.lang.Long
      float :java.lang.Float
      double :java.lang.Double
      char :java.lang.Character
      boolean: java.lang.Boolean

int 与 String 与 char 之间的互相转换的更多相关文章

  1. string与char之间的互相转换

    string对象是一种很强大的存在哈~~ 1. string转const char* string s = "abc"; const char* c_s = s.c_str(); ...

  2. 【转】CString与string、char*的区别和转换

    我们在C++的开发中经常会碰到string.char*以及CString,这三种都表示字符串类型,有很多相似又不同的地方,常常让人混淆.下面详细介绍这三者的区别.联系和转换: 各自的区别 char*: ...

  3. CString string char* char 之间的字符转换(多种方法)

    在写程序的时候,我们经常遇到各种各样的类型转换,比如 char* CString string 之间的互相转换.首先解释下三者的含义. CString 是一种很有用的数据类型.它们很大程度上简化了MF ...

  4. string char * const char *之间的互相转换

    string  ->   const char * 用str的c_str()方法或者data()方法均可,这个两个方法返回值为cong char * string str = "hel ...

  5. CString与string、char*的区别和转换

    转自:http://blog.csdn.net/luoweifu/article/details/20232379 我们在C++的开发中经常会碰到string.char*以及CString,这三种都表 ...

  6. 键盘接收用户输入案例2(案例内容包含键盘接收 int、String、Char、double、boolean)等类型及介绍

    int类型: int age = input.nextInt();    double类型: double score = input.nextDouble(); String类型: String n ...

  7. c++ string 和wstring 之间的互相转换函数

    #include <string> std::string ws2s(const std::wstring& ws) { std::string curLocale = setlo ...

  8. C#中string,char[],byte[]互相转换

    string 转换成 Char[] string ss = "我爱你,中国"; char[] cc = ss.ToCharArray(); Char[] 转换成string str ...

  9. wchar_t*和char*之间的互相转换的那些事

    最近在看一写PE文件格式的东西,想做一个读取PE文件信息的小工具,中间遇到将LPVOID格式无法转换到LPTSTR格式,强制转换屡试屡败,多显示乱码.我们知道LPVOID格式可以直接转换到char * ...

随机推荐

  1. oracle序列使用时 先用伪列将序列的id调整到正确的位置

  2. 【bzoj3931】[CQOI2015]网络吞吐量 最短路+最大流

    题目描述 路由是指通过计算机网络把信息从源地址传输到目的地址的活动,也是计算机网络设计中的重点和难点.网络中实现路由转发的硬件设备称为路由器.为了使数据包最快的到达目的地,路由器需要选择最优的路径转发 ...

  3. HTML5调用手机摄像头,仅仅支持OPPOHD浏览器

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. Codeforces Round #518 Div. 1没翻车记

    A:设f[i][j][0/1]为前i个数第i位为j且第i位未满足/已满足限制的方案数.大力dp前缀和优化即可. #include<iostream> #include<cstdio& ...

  5. [POI2011]Lightning Conductor

    题面在这里 description 已知一个长度为\(n\)的序列\(a_1,a_2,...,a_n\). 对于每个\(1\le i\le n\),找到最小的非负整数\(p\), 满足对于任意的\(1 ...

  6. 周记【距gdoi:110天】

    这两个星期都在复习和考试,进度慢了好多.(考试也觉得似乎不是很理想) 姚老要我们写个程序来应对学校的分班问题.然后我们就脑洞打开准备设计一个.写应用程序应该是很烧时间的吧? 接下来搞搞后缀数组,然后还 ...

  7. [Leetcode] Recover binary search tree 恢复二叉搜索树

    Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing ...

  8. Codeforces Round #478 C. Valhalla Siege

    C. Valhalla Siege time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  9. Ubuntu系统iptables规则的查看和清除

    系统不支持service iptables restart,service iptables status,如何查看与清除iptable的规则呢? 一 iptables查看基本语法 iptables ...

  10. Eclipse中的Web项目自动部署到Tomcat的webapp目录下

    Eclipse中的Web项目自动部署到Tomcat   原因 很长时间没用Eclipse了,近期由于又要用它做个简单的JSP项目,又要重新学习了,虽然熟悉的很快,但记忆总是很模糊,偶尔犯错,以前很少写 ...