I have multiple arrays all with different data types (string, double, int) the data type stays the same for the array but each array has a different data type. Ex. Array1 has string values, Array 2 double values, Array 3 int values. All of which contain negative numbers and I want to convert those negative numbers all into positive and put them back into their respective arrays.
I initially thought of using Math.abs but i'd need to make a loop (i assume a for loop) in which I convert all data values to int and then apply Math.abs to those values. But I'm not sure how I can make the loop work for all the different data types as well as placing the new values back into the respective array's in correct order.
I also thought of using Parseint for the conversion but that only applies to strings going to int which doesn't help with the doubles or ints. I need the code to do it all in one universal loop.
This isn't pretty, but it provides a single method that you can pass an array of Strings, Doubles, or Integers to and get back an array of their absolute values.
Using the method would look like this:
Or, simply: