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
Post a Comment