java--装饰类

package test_1027;

import java.io.BufferedReader;
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 class ioStream {
public static void main(String[] args) throws IOException {

	person p =new person(new Student1());
	p.code();
	
}

}
interface code{
public void code();
}

class Student1 implements 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");

}

}

posted @ 2020-12-23 14:54  雨曼晴川  阅读(85)  评论(0编辑  收藏  举报