public class Demo {
public static void main(String[] args) {
int m = 500;
Integer obj = new Integer(m); // 手动装箱
int n = obj.intValue(); // 手动拆箱
System.out.println("n = " + n);
Integer obj1 = new Integer(500);
System.out.println("obj 等价于 obj1?" + obj.equals(obj1));
}
}
n = 500 obj 等价于 obj1?true
parseInt(String s, int radix);
public class Demo {
public static void main(String[] args) {
String str[] = {"123", "123abc", "abc123", "abcxyz"};
for(String str1 : str){
try{
int m = Integer.parseInt(str1, 10);
System.out.println(str1 + " 可以转换为整数 " + m);
}catch(Exception e){
System.out.println(str1 + " 无法转换为整数");
}
}
}
}
123 可以转换为整数 123 123abc 无法转换为整数 abc123 无法转换为整数 abcxyz 无法转换为整数
public class Demo {
public static void main(String[] args) {
int m = 500;
String s = Integer.toString(m);
System.out.println("s = " + s);
}
}
s = 500
public class Demo {
public static void main(String[] args) {
int m = 500;
Integer obj = m; // 自动装箱
int n = obj; // 自动拆箱
System.out.println("n = " + n);
Integer obj1 = 500;
System.out.println("obj 等价于 obj1?" + obj.equals(obj1));
}
}
n = 500 obj 等价于 obj1?true
package p1.p2;
package p1.p2;
public class Test {
public Test(){
System.out.println("我是Test类的构造方法");
}
}
public class Demo {
public static void main(String[] args) {
java.util.Date today=new java.util.Date();
System.out.println(today);
}
}
Wed Dec 03 11:20:13 CST 2014
import java.util.Date;
// 也可以引入 java.util 包中的所有类
// import java.util.*;
public class Demo {
public static void main(String[] args) {
Date today=new Date();
System.out.println(today);
}
}
package p0;
import p1.p2.Test;
public class Demo{
public static void main(String[] args){
Test obj = new Test();
}
}
package p1.p2;
public class Test {
public Test(){
System.out.println("我是Test类的构造方法");
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有