public class changetype {
public static void main(String[] args)
{
String ar = "true"; //String转 boolean ,只要不是"true",结果即为false;
boolean ar1 = Boolean.parseBoolean(ar);
if(ar1)
{
System.out.println("true"); //结果为true;
} String str = "12"; //String 转 int
int m = Integer.parseInt(str);
System.out.println(m); String str0 = "12.6"; //string转换成double
double x = Double.parseDouble(str0);
System.out.println(x); int y = 5;
String str1 = y+"";
System.out.println(str1); int flag = 100; //int转String,任何类型与字符串连接将变为字符串类型。不推荐使用
String a = flag+"";
System.out.println(a); int flag0 = 200; //int 转String 利用String.valueOf();
String str3 = String.valueOf(flag0);
System.out.println(str3); float h = 12.6f; // float 转 int ,由高到低必须进行强制类型转换,损失精度变为12
int w =(int)h;
System.out.println(w); //结果为12 float c = 89.6666f;
double s = c;
System.out.println(s); //结果为89.666677987979 double e = 78.999999999;
float o = (float)e;
System.out.println(o); //结果为79 }}

最新文章

  1. Hadoop学习笔记—14.ZooKeeper环境搭建
  2. ios - block循环引用Demo示例
  3. bdb log file 预设长度的性能优化
  4. POJ 1502 MPI Maelstrom (Dijkstra)
  5. 《深入剖析Tomcat》阅读(二)
  6. windows 与Linux 互传文件
  7. cocos2d-x 3.0rc2 对于每个包执行情况的重要平台 (超级方便)
  8. SQL的各种连接(cross join、inner join、full join)的用法理解
  9. 中间件详解,Django复习
  10. WORDPRESS博客完美更换网站空间服务器的方法
  11. SecureCRT标签显示标题
  12. Python全栈之路----常用模块----hashlib加密模块
  13. 洛谷-p2764(最小路径覆盖)(网络流24题)
  14. centos查看端口被哪个应用端口占用命令
  15. QT插件+ROS 2 新建项目
  16. [UE4]解决角色影子的问题
  17. Q in Q
  18. eclipse 安装properties编辑器,显示中文
  19. Scala中使用implict 扩展现有类的方法
  20. AngularJS中Directive指令系列 - bindToController属性的使用

热门文章

  1. Java经典编程题50道之二十八
  2. PHP函数register_shutdown_function的用法
  3. python file文件操作--内置对象open
  4. HttpURLConnection发送请求
  5. 数据排序--vue
  6. R︱mlr包帮你挑选最适合数据的机器学习模型(分类、回归)+机器学习python和R互查手册
  7. R+tmcn笔记︱tmcn包的基本内容以及李舰老师R语言大会展示内容摘录
  8. HI3531的nand flash测试
  9. Java获取当前的年月
  10. Error Code: 1630. FUNCTION rand.string does not exist