This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Enum version | |
public enum EnumSingleton { | |
INSTANCE; | |
} | |
// Classic version | |
public class ClassicSingleton { | |
private static ClassicSingleton instance; | |
private ClassicSingleton() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.stream.IntStream; | |
public class MergeArray { | |
public int[] mergeArrays(int[] array1, int[] array2) { | |
return IntStream.concat(Arrays.stream(array1), Arrays.stream(array2)) | |
.sorted() | |
.toArray(); | |
} | |
} |
NewerOlder