I have a String array and I want to convert it into BigInteger array using Java 8 streams.
String[] output = bigSorting(new String[]{"31415926535897932384626433832795", "1", "4900146572543628830293235422623540449026979", "10", "57500297590012603652986133599394871645776460", "5",
"497010206818067722087306230802257700034825862515267073569769100385728461314", "57500297590012603652986133599394871645776460497010206818067722087306230802257700034825862515267073569769100385728461314497010206818067722087306230802257700034825862515267073569769100385728461314497010206818067722087306230802257700034825862515267073569769100385728461314497010206818067722087306230802257700034825862515267073569769100385728461314497010206818067722087306230802257700034825862515267073569769100385728461314"});
Object[] unsortedBigIntegerArr = convertFromStringArrayToBigIntegerArray(output);
This is what I have tried but I am not able to get BigInteger array, I am able to get the Object array though.
private static Object[] convertFromStringArrayToBigIntegerArray(String[] unsorted) {
return Arrays.stream(unsorted).map(BigSorting2::convertFromStringToBigInteger).toArray();
}
private static BigInteger convertFromStringToBigInteger(String unsorted) {
return new BigInteger(unsorted);
}
Is there any way I can do it completely using Java 8 streams.