List<?> with both strings and numbers

Viewed 49

I am doing exercise and i have this situation, where i need to count the sum of the numbers, where the integers are as strings or numbers, but in the same array. One of the test cass is:

@Test
    public void test_5() {
        assertEquals(45, mixedSum.sum(Arrays.asList("1", "5", "8", 8, 9, 9, 2, "3")));
    }

I understand the logic of the exercise, but I want to recreate in my IDE to understand it better. I know that it's not the "best" way to go with that, but the List that we see in the @test comes from ArrayList < Object > foo = new ArrayList<>()?

Update:

To be more precise, i meant in what way the mentioned list was made? Declaring List as Object type and then putting different values to it or there is some other way to do that?

0 Answers
Related