Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- class X1 {
- private final int x1 = 41;
- private X1 X1;
- public X1(X1 x1) { X1 = x1; }
- void print() {
- System.out.println(x1);
- }
- }
- class X2 {
- private final int x2 = 42;
- private X2 X2;
- public X2(X2 x2) { X2 = x2; }
- void print() {
- if (!X2.equals(this)) System.out.println(x2);
- }
- }
- class X3 {
- private final int x3 = 43;
- private X3 X3;
- void X3(X3 x3) { X3 = x3; }
- void print() {
- if (X3.equals(this)) System.out.println(x3);
- }
- }
- public class Main {
- public static void main(String[] args) {
- // your code goes here
- // print x1, x2 and x3
- // by invoking method print() of each class
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement