java--装饰类

2021-03-09 11:30

阅读:539

标签:iostream   java   ide   main   throw   rgs   exce   pack   out   

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");

}

}

java--装饰类

标签:iostream   java   ide   main   throw   rgs   exce   pack   out   

原文地址:https://www.cnblogs.com/cloudLi/p/14178621.html


评论


亲,登录后才可以留言!