-
-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Program on Java #7
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ public static void main(String[] args) { | |
int i = 0; | ||
do { | ||
System.out.println(i++); | ||
|
||
}while (i < 10); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still needs code formatting. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ | |
public 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()))); | ||
list.forEach(item -> System.out.println(String.format("%s, %s, %s",item,list.indexOf(item), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code formatting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't undestrand, how to formatting this code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can have a look at Google Java Style Guide. Your IDE definitely provides tools to format code according to the selected code style. For example, if you use IntellijIdea, you can format your code using Alt + Cmd + L. |
||
list.toString()))); | ||
System.out.println(); | ||
list.forEach(System.out::print); | ||
System.out.println(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ public class Map { | |
public static void main(String[] args) { | ||
|
||
Function<Integer,Void> log = s -> {System.out.println(s); return null;}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code style. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a |
||
Arrays.stream(new Integer[]{7, 10, 1, 5, 2}).map(x -> x * 2).map(log); | ||
Arrays.stream(new Integer[]{7, 10, 1, 5, 2}).map(x -> x * 2).forEach(System.out::println); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatting.