Beginner Java project: how to delete an element from an array when it is one of the parameters?

Im working on a coin sorter project. At the moment I'm trying to create a method that takes two values (total value, and a type of coin), and will return the total value sorted out into all the coin denominations EXCEPT the type of coin. For example multiCoinCalculator(562, 50) would return "2x200p, 1x100p, 0x50p, 3x20p, 0x10p with a remainder of 2p".

I have a pretty good idea of how to do this but I am struggling to remove a value the "type of coin" value from my array.

//multiCoinCalculator method

    public String multiCoinCalculator(int totalValExchange, int coinType) {
        int[] list= {10,20,50,100,200};
        list = ArrayUtils.removeElement(list, coinType);
        return list;

Here you can see what I am trying to do so far. I am just wanting to remove the coin type (would be 50 with the example), from my list. I have been fiddling with it for ages but cant seem to get it to work at all!

The errors that come up are "ArrayUtils cannot be resolved" and "type mismatch: cannot convert from int[] to String"

Any ideas? Would be greatly appreciated!

Read more here:

Content Attribution

This content was originally published by Millyfg at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: