Differences between List.of and Arrays.asList in Java

Four main differences between List.of method, added in Java 9, and old one Arrays.asList 
31 October 2017   2869

In Java 9, there is new Collection Factory methods, called List.of:

List<String> strings = List.of("first", "second");

Let's figure out what's the difference between the previous and the new options.

There are 4 main differences:

Arrays.asList returns a mutable list while the list returned by List.of is immutable:

List<Integer> list = Arrays.asList(1, 2, null);
list.set(1, 10); // OK

List<Integer> list = List.of(1, 2, 3);
list.set(1, 10); // Fails

Arrays.asList allows null elements while List.of doesn't:

List<Integer> list = Arrays.asList(1, 2, null); // OK
List<Integer> list = List.of(1, 2, null); // Fails with a NullPointerException

contains method behaves differently with nulls:

List<Integer> list = Arrays.asList(1, 2, 3);
list.contains(null); // Return false

List<Integer> list = List.of(1, 2, 3);
list.contains(null); // Throws NullPointerException

Arrays.asList returns a view of the passed array, so the changes to the array will be reflected in the list too. For List.of this is not true:

Integer[] array = {1,2,3};
List<Integer> list = Arrays.asList(array);
array[1] = 10;
System.out.println(list); // Prints [1, 10, 3]

Integer[] array = {1,2,3};
List<Integer> list = List.of(array);
array[1] = 10;
System.out.println(list); // Prints [1, 2, 3]    

 

Bisq Decentelized Exchange v. 1.0 Released

According to GitHib repository, it is written in Java programming language
16 April 2019   290

The developers of Bisq presented a new version of the decentralized exchange (v1.0).

The project repository on GitHub notes that version 1.0 is the most important milestone in the development of the Bisq platform.

Thus, the new version of the software implements a decentralized autonomous organization mechanism (Bisq DAO). It allows exchange users to directly participate in project management.

For example, those who contribute to the development of Bisq may receive rewards in BSQ tokens. Also, the use of these assets can reduce trade commissions by 90%.

Among other changes - bug fixes, minor improvements to the user interface.