package New_Dao;
public class Chinese {
//记录了构造器调用次数
public Chinese(){
Chinese.count++;
}
// public static String country; //定义静态变量作用全局
static String country; //定义静态变量作用全局 //常量 类变量
String name ;
int age;
public static int count; //计数
public static boolean StrisNull(String str) {
if (str != null && !str.equals("")) {
return true; //判断是否为字符串
}
return false;
}
public static void showCount (){
System.out.println(“总共new了”+Chinese.count + “个对象”);
}
public static void main(String[] args) {
Chinese.country= "中国"; // 使用静态全局变量
Chinese ch = new Chinese();
Chinese ch1 = new Chinese();
showCount();
Chinese ch2 = new Chinese();
Chinese ch3 = new Chinese();
showCount();
Chinese ch4 = new Chinese();
ch.age=18;
ch.name="root";
String s = "";
System.out.println(StrisNull(s));
}
}