Skip to content

Added Java examples #3

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added Java examples #3

wants to merge 1 commit into from

Conversation

CptNeemoo
Copy link

Added Java examples

Added Java examples
@GYFK GYFK requested a review from lidaamber June 6, 2017 21:42
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. Just a few changes.

@@ -0,0 +1,8 @@
class For {
public static void main(String[] args)
{

Choose a reason for hiding this comment

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

Code style.

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.

class ForOf {
public static void main(String[] args) {
for (int element : 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.

class Break {
public static void main(String[] args) {
label1: 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.

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

Choose a reason for hiding this comment

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

For this example you should better use forEach(System.out::println) instead of map(log).

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

Successfully merging this pull request may close these issues.

2 participants