Easy solution with Java Stream
\u21161\nJava\nclass Solution {\n    public int[] sortArrayByParity(int[] nums) {\n        return Arrays.stream(Arrays.stream(nums).boxed().toArray(Integer[]::n
# \u21161\n```Java\nclass Solution {\n    public int[] sortArrayByParity(int[] nums) {\n        return Arrays.stream(Arrays.stream(nums).boxed().toArray(Integer[]::new))\n                .sorted(Comparator.comparingInt(n -> (int) n % 2 == 0 ? 0 : 1))\n                .mapToInt(x -> x)\n                .toArray();\n    }\n}\n```\n# \u21162\n\n```Java\nclass Solution {\n    public int[] sortArrayByParity(int[] nums) {\n        List<Integer> list = new ArrayList<>(nums.length);\n        list.addAll(Arrays.stream(nums).filter(n -> n % 2 == 0).boxed().collect(Collectors.toList()));\n        list.addAll(Arrays.stream(nums).filter(n -> n % 2 != 0).boxed().collect(Collectors.toList()));\n        return list.stream().mapToInt(x -> x).toArray();\n    }\n}\n```\n\n\n\n\n
['Java']