/**
*一切事物都是对象,对象就是可以看到的,感觉到的,听到的,触摸到的,尝到的和闻到的东西
* 对象是一个自包含的实体,用一组可识别的特性和行为来标识
* 类就是具有相同的属性和功能的对象的抽象的集合(模板)
* class是定义类的关键字
* * 凡是重复两次及以上的代码块都用一个函数或类或接口来封装
* 驼峰命名
* java习惯类名的首字母要大写。多个单词则各个单词首字母大写
* 方法名的第一个单词首字母小写,第二个单词及第二个单词以后单词首字母大写
* 变量的第一个单词首字母小写,第二个单词及第二个单词以后单词首字母大写
* 对外公开的方法要用public来修饰
* 实例就是一个真实的对象
* 实例化就是创建对象的过程,使用new关键字来创建对象
*/
public class Test {
public static void main(String[] args) {
Test test ;//声明对象,Test为对象test的类型
//shift+enter键是直接从本行切换到下一行的快捷键
test = new Test();//将test对象实例化,创建test对象
//tab键自动补齐
test.print(test.shout());
}
public void print(String stringTypeVariety){
System.out.println(stringTypeVariety);
}
public String shout(){
return "喵";
}
}
public class Cat extends Test {
//方法的重写
public String shout(){
return "喵喵喵";
}
public static void main(String[] args) {
new Test().print(new Cat().shout());
new Cat().print(new Test().shout());
}
}