[HD-OCP17/21-Fundamentals Pg 489, Sec. 17.1.6 - the-foreach-method]

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 489, Sec. 17.1.6 - the-foreach-method]

Post by raphaelzintec »

hello

can you explain me this, why BiConsumer<String, Integer> accepts method having double primitive type argument and prints double not integer:

Code: Select all

... main code...

        BiConsumer<String, Integer> biConsumerMR = MyClass::showNameAge;
        biConsumerMR.accept("bob", 50);
    }
... end main...

    static void showNameAge(String name, double age){
        System.out.println(name+" "+age);
    }

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests