GenuineSounds icon

Casting Expressions

GenuineSounds | PRO | 01/23/16 12:41:25 AM UTC | 0 ⭐ | 521 👁️ | Never ⏰ | []
Java |

1.02 KB

|

None

|

0 👍

/

0 👎

package ninja.genuine.brainfuck;
 
/**
 * The output of this program is:
 * true
 * false
 * false
 * false
 * true
 * false
 * true
 * true
 * true
 */
public class BrainFuck {
 
    public static Something foo    = (Something & Foo) v -> {};
    public static Something bar    = (Something & Bar) v -> {};
    public static Something fooBar = (Something & Foo & Bar) v -> {};
 
    public static void main(String[] args) {
        System.out.println(foo instanceof Foo);
        System.out.println(foo instanceof Bar);
        System.out.println(foo instanceof Foo && foo instanceof Bar);
        System.out.println(bar instanceof Foo);
        System.out.println(bar instanceof Bar);
        System.out.println(bar instanceof Foo && bar instanceof Bar);
        System.out.println(fooBar instanceof Foo);
        System.out.println(fooBar instanceof Bar);
        System.out.println(fooBar instanceof Foo && fooBar instanceof Bar);
    }
 
    public static interface Something {
 
        void noop(Object o);
    }
 
    public static interface Foo {}
 
    public static interface Bar {}
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎