java - Boolean 'if' statement does not work -


this code meant return congratulations when 2 arrays both in same order. have print both arrays test , become same order message 'congratulations'does not print. can please help??

        boolean truefalse = arrays.equals(original, currentarr);         if (truefalse == true){             system.out.println("congratulations");             var1 = var1 + var2;          } 

arrays.equals(object[] a, object[] a2) compares members of arrays equals. therefore, 2d arrays, when members arrays themselves, compares references (since arrays don't override object's equals).

use arrays.deepequals instead.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -