package com.neusoft.constant;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
public class WarpDemo {
public int m1(String age) {
int a = Integer.parseInt(age);
return a;
}
public int m1(Integer integer) {
int a = 10;
int c = integer + a;
return c;//20
}
public static void main(String[] args) {
WarpDemo wDemo = new WarpDemo();
System.out.println(wDemo.m1(10));//10封装进integer再解封
Scanner input = new Scanner(System.in);
String age = input.next();
WarpDemo wDemo1 = new WarpDemo();
int a = wDemo1.m1(age);
System.out.println(a);
// 将基本类型转换为包装类型
int aa = 500;
Integer integer = new Integer(aa);
System.out.println(integer);//500
// 将包装类型转换为基本类型
Integer integer2 = new Integer(50);
int val = integer2.intValue();
System.out.println(val);//50
Date date = new Date();
System.out.println(date);//Mon Apr 02 23:14:33 CST 2018
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.out.println(simpleDateFormat.format(date));
//2018-04-02 11:14:33
}
}
package com.neusoft.constant;
public class Person {
private Integer sid;
private double salary;
private String name;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public static void main(String[] args) {
Person person1 = new Person();
System.out.println(person1.hashCode());//分配地址
System.out.println(person1);//默认toString
Person person2 = new Person();
System.out.println(person2.hashCode());
System.out.println(person2);
}
}
package com.neusoft.constant;
public class Test {
public static void main(String[] args) {
String s = "abc";
if("abc".equals(s)){
System.out.println("success......");
}
Person person1 = new Person();
Person person2 = new Person();
System.out.println(person1.equals(person2));
//输出为false,因为两个对象的地址也将进行比较
}
}