Last active
May 29, 2017 09:29
-
-
Save jneira/bf75d507be0a3005dc37f24052cdba68 to your computer and use it in GitHub Desktop.
This file contains 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
import java.util.List; | |
import java.util.stream.Stream; | |
import static java.util.stream.Collectors.*; | |
public class Prueba { | |
public static void main(String[] args) { | |
Integer i=getInt(new Integer(2)); | |
int j=getInteger(3); | |
System.out.println(idsToStringList(new Person(i),new Person(j))); | |
idsToString(new Person(i),new Person(j)).forEach(System.out::println); | |
} | |
public static int getInt(int i) { | |
return i; | |
} | |
public static Integer getInteger(Integer i) { | |
return i; | |
} | |
public static Stream<String> idsToString(Person ...persons) { | |
return Stream.of(persons).map(x -> Integer.toString(x.id())); | |
} | |
public static List<String> idsToStringList(Person ...persons) { | |
return Stream.of(persons) | |
.collect(mapping(x -> Integer.toString(x.id()),toList())); | |
} | |
} | |
class Person { | |
private int id=0; | |
public Person(Integer i) { | |
this.id=i; | |
} | |
public int id() {return id;} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment