S
S
Shefinea2017-04-06 22:03:23
Java
Shefinea, 2017-04-06 22:03:23

Java How to make a list of type B from a list of type A without using loops?

class A{}
class B{
B(A a){}
}
class C {
A a1, a2,a3,a4;
List aList = new ArrayList<>(); List bList; ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Khrustalev, 2017-04-06
@Shefinea

List<A> aList = ...
List<B> bList = aList.stream().map(B::new).collect(Collectors.toList());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question