class Test1{ //创建一个Test类,名称为Test1
public int a; //定义一个public权限的int型成员变量
public char b; //定义一个public权限的char型成员变量
}
public class Test{ //主类
public static void main(String[] args){ //主方法
Test1 t1 = new Test1();
Test1 t2 = new Test1(); //两个实例化对象
System.out.println(t1.a);
System.out.println(t2.b); //通过对象调用成员变量
}
}
public class Test{
public static void main(String[] args) {
if(args.length<0){
System.out.println("没有传递参数");
}else{
int n = 10;
for(int i = 1; i <= n;i++){
System.out.print(fibonacci(i)+"、");
}
}
}
public static int fibonacci(int args){
if(args<=1){
return args;
}else{
return fibonacci(args-1)+fibonacci(args-2);
}
}
}
class fun{ //创建一个类,类名称fun
public fun(){ //无参构造方法
System.out.println("Hello Constructor"); //在构造方法中打印字符串
}
public fun(String s){ //重载这个构造方法,并接受一个字符串参数
this(); //用this来调用本类方法
System.out.println(s); //在重载方法中打印这个字符串参数
}
}
public class Test { //主类
public static void main(String[] args) { //主方法
new fun(); //匿名对象
}
}