-
-
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?
Conversation
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.
Thanks for your work, but what is the purpose of your PR? Have a look at existing PRs in this repo. The same one already exists and it requires changes very similar to your ones.
Secondly, you should format your code and add code style changes.
src/src/DoWhile.java
Outdated
do { | ||
System.out.println(i++); | ||
|
||
}while (i < 10); |
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.
src/src/For.java
Outdated
public class For { | ||
public static void main(String[] args) { | ||
for (int i = 0; i < 10; i++) | ||
{ |
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 style.
src/src/ForEach.java
Outdated
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()))); |
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.
Could you split this line to fit 100 symbols in line, please?
public class ForOf { | ||
public static void main(String[] args) { | ||
for (int elem: new int[]{7, 10, 1, 5, 2}) | ||
{ |
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 style.
src/src/Map.java
Outdated
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Using a forEach()
, you don't need this function at all.
public static void main(String[] args) { | ||
int i = 0; | ||
while (i<10) | ||
{ |
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 style.
src/src/Map.java
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather use forEach()
instead of map()
for this example.
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.
Thanks, could you format your code, please?
src/src/Map.java
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Using a forEach()
, you don't need this function at all.
@@ -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 comment
The 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 comment
The 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 comment
The 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.
src/src/DoWhile.java
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Still needs code formatting.
do { | ||
System.out.println(i++); | ||
}while (i < 10); | ||
do {System.out.println(i++);}while (i < 10); |
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.
Ditto.
No description provided.