Comparison between groups in Java

xiaoxiao2021-03-06  14

// NULL element is equal.

Boolean [] Barr1 = NULL;

Boolean [] Barr2 = NULL;

Boolean B = Arrays.Equals (Barr1, Barr2); // True

// Compare two Boolean arrays.

Barr1 = new boolean [] {true, false};

Barr2 = new boolean [] {true, false};

B = arrays.equals (barr1, null); // false

B = arrays.equals (barr1, barr2); // true

// For the array of native types, equals () can be used.

B = arrays.equals (new byte [] {0}, new byte [] {0}); // True

B = arrays.equals (new char [] {'a'}, new char [] {'a'}); // true

B = arrays.equals (new short [] {0}, new rain [] {0}); // true

B = arrays.equals (new int in {{0}, new int "{0}); // true

B = arrays.equals (new long [] {0L}, new long [] {0L}; // true

B = arrays.equals (new float [] {0f}, new float [] {0f}); // true

B = arrays.equals (new double [] {0D}, new double [] {0D}); // True

// If the comparison is an Object type array, the NULL element is equal.

// If the element is not NULL, the Java virtual machine will automatically call Object.Equals ().

B = arrays.equals (new string [] {"a"}, new string [] {"a"}); // true

B = arrays.equals (new string "{null}, new string [] {null}; // true

B = arrays.equals (new string [] {"a"}, new string [] {null}); // false

转载请注明原文地址:https://www.9cbs.com/read-46019.html

New Post(0)