Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

Filip2402
Copy link

No description provided.

Copy link

@lidaamber lidaamber left a 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.

do {
System.out.println(i++);

}while (i < 10);

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++)
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style.

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())));

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})
{

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;};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style.

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)
{

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);

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.

Copy link

@lidaamber lidaamber left a 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;};

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),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code formatting.

Copy link
Author

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?

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.

@@ -6,7 +6,6 @@ public static void main(String[] args) {
int i = 0;
do {
System.out.println(i++);

}while (i < 10);

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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants