Intege data has a longvalue () function, which can be converted into the data of the Long type
code is as follows:
public static void main(String args[]) {
Integer a = 1;
System.out.println(a);
long b = a.longValue();
System.out.println(b);
List<Integer> aList=new ArrayList<>();
Integer a1 = 2;
Integer a2 = 3;
aList.add(a);
aList.add(a1);
aList.add(a2);
List<Long> bList = new ArrayList<>();
aList.stream().forEach(item->{
long temp = item.longValue();
bList.add(temp);
});
System.out.println(bList);
}
Run results:
1
1
[1, 2, 3]