Skip to content

Instantly share code, notes, and snippets.

@jneira
Last active May 29, 2017
Embed
What would you like to do?
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