Added Java examples#3
Open
CptNeemoo wants to merge 1 commit intoHowProgrammingWorks:masterfrom
CptNeemoo:master
Open
Added Java examples#3CptNeemoo wants to merge 1 commit intoHowProgrammingWorks:masterfrom CptNeemoo:master
CptNeemoo wants to merge 1 commit intoHowProgrammingWorks:masterfrom
CptNeemoo:master
Conversation
Added Java examples
lidaamber
requested changes
Jun 6, 2017
lidaamber
left a comment
There was a problem hiding this comment.
Thanks for your work. Just a few changes.
| @@ -0,0 +1,8 @@ | |||
| class For { | |||
| public static void main(String[] args) | |||
| { | |||
| public static void main(String[] args) { | ||
| int i = 0; | ||
| while (i < 10) | ||
| { |
| class ForOf { | ||
| public static void main(String[] args) { | ||
| for (int element : new int[]{7, 10, 1, 5, 2}) | ||
| { |
| class Break { | ||
| public static void main(String[] args) { | ||
| label1: for (int i = 0; i < 10; i++) | ||
| { |
| class ForEach { | ||
| public static void main(String[] args) { | ||
| List<Integer> list = Arrays.asList(7, 10, 1, 5, 2); | ||
| list.forEach(item -> System.out.println(String.format("%s, %s, %s",item,list.indexOf(item),list.toString()))); |
There was a problem hiding this comment.
Could you move a part of this line to the next to fit 100 symbols in line, please? This is a code style mistake.
| class Map { | ||
| public static void main(String[] args) { | ||
| Function<Integer,Void> log = s -> {System.out.println(s); return null;}; | ||
| Arrays.stream(new Integer[]{7, 10, 1, 5, 2}).map(x -> x * 2).map(log); |
There was a problem hiding this comment.
For this example you should better use forEach(System.out::println) instead of map(log).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added Java examples