• + 2 comments

    Slight tweak:

    static String catAndMouse(int x, int y, int z) {
        switch(Integer.compare(Math.abs(z-x), Math.abs(z-y))){
            case -1: return "Cat A";
            case 1: return "Cat B";
            default: return "Mouse C";
        }
    }