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");
}
}
******************************人因为有理想、梦想而变得伟大,而真正伟大就是不断努力实现理想、梦想*****************************