Type of parameter to Lambda

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

Moderator: admin

Post Reply
Emanuel_Swe
Posts: 2
Joined: Tue Mar 27, 2018 8:42 am
Contact:

Type of parameter to Lambda

Post by Emanuel_Swe »

Hello. I wonder if there is a special reason for writing the type

Code: Select all

(Data x) ->
in the lambda expression. You wrote that the expression in first option was syntactically correct.

Greetings V. Ekholm
Attachments
Q 52 in enthuware.ocajp.i.v8.2.1469
Q 52 in enthuware.ocajp.i.v8.2.1469
Question 52.jpg (193.6 KiB) Viewed 2399 times

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

Re: Type of parameter to Lambda

Post by admin »

As the explanation says, the variable name in the lambda cannot be d because d is already used in the method. That is why even though syntax of the lamda in option 1 is correct but it will not compile. Data x doesn't have that problem.

Emanuel_Swe
Posts: 2
Joined: Tue Mar 27, 2018 8:42 am
Contact:

Re: Type of parameter to Lambda

Post by Emanuel_Swe »

Thank you, I just wonder why it says "(Data x)->" and not just "(x)->"

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

Re: Type of parameter to Lambda

Post by admin »

There is no special reason for that.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests