added lambda functions examples and articles (#5941)

pull/5944/head
Leni Kirilov 5 months ago committed by GitHub
parent 09e345f48b
commit ce6e2ff71e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      src/data/roadmaps/java/content/100-java-fundamentals/103-functions.md

@ -4,11 +4,19 @@ A method/function is a way to perform some task. Similarly, in programming like
Steps -
1. Define function - datatype function_name(parameters){body}
2. Call function - function_name(values)
1. Define function - `datatype function_name(parameters){body}`
2. Call function - `function_name(values)`
3. Lambda functions - `x -> x + 1`
4. Pass a function as a variable -
```
final Consumer<Integer> simpleReference1 = App::someMethod1;
simpleReference1.accept(1);
```
Visit the following resources to learn more:
- [@article@Methods/Functions in Java.](https://www.javatpoint.com/method-in-java)
- [@article@Learn Functions/Methods in Java](https://www.w3schools.com/java/java_methods.asp)
- [@video@Functions / Methods in Java](https://www.youtube.com/watch?v=vvanI8NRlSI)
- [@video@Lambda functions](https://www.w3schools.com/java/java_lambda.asp)
- [@video@Passing functions as a variable](https://northcoder.com/post/passing-java-functions-in-variables/)

Loading…
Cancel
Save