The saddest thing is that af|

柒木木木

园龄:2年8个月粉丝:9关注:0

包装类

1. Integer类和Character类的常用方法

public class WrapperMethod {
public static void main(String[] args) {
// Integer类和Character类的常用方法
System.out.println(Integer.MIN_VALUE);//返回最小值
System.out.println(Integer.MAX_VALUE);//返回最大值
System.out.println(Character.isDigit('a'));// 判断是不是数字
System.out.println(Character.isLetter('a'));//判断是不是字母
System.out.println(Character.isUpperCase('a'));//判断是不是大写
System.out.println(Character.isLowerCase('a'));//判断是不是小写
System.out.println(Character.isWhitespace('a'));//判断是不是空格
System.out.println(Character.toUpperCase('a'));//转成大写
System.out.println(Character.toLowerCase('A'));//转成小写
}
}

2. 类型转换

public class WrapperVSString {
public static void main(String[] args) {
//包装类(Integer) -> String
Integer i = 100;
//方式一
String str1 = i + "";
//方式二
String str2 = i.toString();
//方式三
String str3 = String.valueOf(i);
//String -> 包装类(Integer)
String str4 = "1234";
Integer i2 = Integer.parseInt(str4);//使用自动装箱
Integer i3 = new Integer(str4);//使用构造器
}
}

本文作者:柒木木木

本文链接:https://www.cnblogs.com/qimu666/articles/16586624.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   柒木木木  阅读(4)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起