[HD-OCP17/21-Fundamentals Pg 299, Sec. 12.5.0 - enhancing-case-labels-with-guards]

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
raphaelzintec
Posts: 167
Joined: Sun Apr 21, 2024 10:43 am
Contact:

[HD-OCP17/21-Fundamentals Pg 299, Sec. 12.5.0 - enhancing-case-labels-with-guards]

Post by raphaelzintec »

why no dominance here?

Code: Select all

Object obj = 10;
        final int a = 50;
        switch(obj){
            case Integer d when a==a : {
                System.out.println("Integer "+d);
                break;
            }
            case Double d when a==a : {
                System.out.println("Double "+d);
                break;
            }
            default : System.out.println("Object "+obj);
        }

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD-OCP17/21-Fundamentals Pg 299, Sec. 12.5.0 - enhancing-case-labels-with-guards]

Post by admin »

Note sure which one you think dominates the other here? Integer and Double have no parent/child relation.

raphaelzintec
Posts: 167
Joined: Sun Apr 21, 2024 10:43 am
Contact:

Re: [HD-OCP17/21-Fundamentals Pg 299, Sec. 12.5.0 - enhancing-case-labels-with-guards]

Post by raphaelzintec »

right sorry i didnt know type must have relation

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests