Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- interface YouFace {
- String getName();
- }
- static class Posylatel<Y> {
- Y you;
- Posylatel(Y you) {
- this.you = you;
- }
- public void say() {
- System.out.printf("Poshol na huy %s\n", ((YouFace)you).getName());
- }
- }
- static class You implements YouFace {
- private final String name;
- You(String name) {
- this.name = name;
- }
- @Override
- public String getName() {
- return name;
- }
- }
- public static void main(String[] args) {
- var me = new Posylatel<YouFace>(new You("Pidor"));
- me.say();
- }
- }
Add Comment
Please, Sign In to add comment