I’m sure I’m doing something really dumb and basic here but I can’t seem to figure this out. I basically have a method that takes a bunch of numbers, does some work and returns a List of integers.
I then take that list and send it to a method to do some more work on but when I was getting errors because JVM thinks its an object. Here’s a simple example(I’m editing it a bit so you get the idea and its not super long):
public static List normalizer_list(double[] data) {
List normalizer_list = new ArrayList();
for (double current_data : data) {
Integer modified_data = (int) (current_data *1000);
normalizer_list.add(modified_data);
}
return normalizer_list;
}
private static void do_some_work(List normalizer_list) {
// TODO Auto-generated method stub
for (int i = 0; i < norm_data.size(); i++) {
Integer current_norm_data = (int) normalizer_list.get(i);
At first I tried to do math with norm_data.get(i) but it gave me errors because it thought it was a object, so I tried to cast it to an Integer and it says I can’t do that. What am I doing wrong(is it the way I’m using the list?)
Cast as an
Integer:Or better yet, make
normalizer_listaList<Integer>, then accept an integer list in thedo_some_workmethod.