のJavaラッパークラスの整数の例

免責事項:この記事はブロガーオリジナル記事です、続くBY-SAのCC 4.0を著作権契約、複製、元のソースのリンクと、この文を添付してください。
このリンク: https://blog.csdn.net/weixin_45778981/article/details/102754285

JavaラッパークラスはAPIにjava.langパッケージで見ることができています

のJavaラッパークラスの整数の例

public class testInteger {
	
	public static void main(String[] args) {
		Integer i1=new Integer(123);
		Integer i2=new Integer("123");
		System.out.println((i1==i2));
		System.out.println(i1.equals(i2));
		System.out.println(i2.toString());//说明Integer类重写了toString方法

		//1.Integer-->int
		int i=i1.intValue();
		System.out.println(Integer.max(10,20));
		//2.int-->Integer
		Integer i4=Integer.valueOf(123);
		//3.String -->int
		int ii=Integer.parseInt("345");
		//4.int -->String
		String str=ii+"";
		String s=String.valueOf(ii);
		//5.string-->Integer
		Integer i5=new Integer("456");
		//6.Integer-->String
		String ss=i5.toString();
		System.out.println(ss);
		}
			
}

おすすめ

転載: blog.csdn.net/weixin_45778981/article/details/102754285