java--装饰类
2021-03-09 11:30
标签:iostream java ide main throw rgs exce pack out package test_1027; import java.io.BufferedReader; public class ioStream { } class Student1 implements code{ } } java--装饰类 标签:iostream java ide main throw rgs exce pack out 原文地址:https://www.cnblogs.com/cloudLi/p/14178621.html
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Scanner;
import java.util.TreeMap;
public static void main(String[] args) throws IOException { person p =new person(new Student1());
p.code();
}
interface code{
public void code();
}@Override
public void code() {
System.out.println("Student");
}
class person implements code{
private Student1 s;
public person (Student1 s) {
this.s= s;
}
@Override
public void code() {
s.code();
System.out.println("person");}