小编Dmi*_*meh的帖子

Sort numbers in an array without changing even numbers position using Java-8

I’m learning Java 8 streams. Tell me pls, how can I write a sortArray method more compactly?

import org.junit.Test;    
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.assertArrayEquals;

public class TestStream {

    /*
     * Sort numbers in an array without changing even numbers position
     */

    @Test
    public void test_1() {
        int[] nonSorted = new int[]{3, 4, 5, 2, 1, 6, 9, 8, 7, 0};
        int[] expected = new int[]{1, 4, 3, 2, 5, 6, 7, 8, 9, 0}; …
Run Code Online (Sandbox Code Playgroud)

java java-8 java-stream

9
推荐指数
1
解决办法
638
查看次数

标签 统计

java ×1

java-8 ×1

java-stream ×1