package top.qaqaq.java.P649;
import java.io.Serializable;
/**
* @author RichieZhang
* @create 2022-11-01 下午 7:52
*/
public class Creature<T> implements Serializable {
private char gender;
public double weight;
private void breath(){
System.out.println("生物呼吸");
}
public void eat(){
System.out.println("生物吃东西");
}
}
package top.qaqaq.java.P649;
/**
* @author RichieZhang
* @create 2022-11-01 下午 7:52
*/
@MyAnnotation(value = "hi")
public class Person extends Creature<String> implements Comparable<String>,MyInterface{
private String name;
int age;
public int id;
public Person(){
}
@MyAnnotation(value = "abc")
private Person(String name){
this.name = name;
}
Person(String name, int age){
this.name = name;
this.age = age;
}
@MyAnnotation
private String show(String nation){
System.out.println("我的国籍是:" + nation);
return nation;
}
public String display(String interests,int age) throws NullPointerException,ClassCastException{
return interests + age;
}
@Override
public int compareTo(String o) {
return 0;
}
@Override
public void info() {
System.out.println("我是一个人");
}
}
package top.qaqaq.java.P649;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
/**
* @author RichieZhang
* @create 2022-11-01 下午 8:02
*/
@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, MODULE})
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
String value() default "hello";
}
package top.qaqaq.java.P649;
/**
* @author RichieZhang
* @create 2022-11-01 下午 7:55
*/
public interface MyInterface {
void info();
}