There is, say, such a code:

String m = "1101101"; boolean[] check = new boolean[7]; conversion(m, check); for(boolean v : check){ System.out.println(v); } public void conversion(String days, boolean[] checkDays){ for(int i = 0; i < days.toCharArray().length; i++){ char p = days.toCharArray()[i]; System.out.println(p); if(days.toCharArray()[i] == '1'){ checkDays[i] = true; } else { checkDays[i] = false; } } } 

sout (p) displays everything correctly: "1101101", and sout (v) always displays "false". I understand that the error in comparison may lie on the surface, but I can not notice.

Closed due to the fact that it was off-topic by the participants andreycha , aleksandr barakin , Saidolim , Streletz , sercxjo 4 Sep '16 at 21:51 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reasons:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - andreycha, aleksandr barakin, sercxjo
  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Saidolim, Streletz
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    What are sout(p) and sout(v) ? - s8am
  • @ s8am, System.out.println (p) and System.out.println (v) - Ivan
  • This method works correctly for me. Show all your code. - s8am
  • After boolean[] check = new boolean[7]; - each element of the check array is false . I think you and they do not change. - s8am
  • @ s8am, 160 lines? I have nowhere else used neither this method nor the variables. I seem to look and understand that everything should work, but as if he refuses to compare == '1' and immediately goes to else - Ivan

1 answer 1

The problem was solved in a strange way. During debugging, for some reason I saw an array in the console, which I deleted a long time ago (I don’t understand what he was doing there, because he was no longer in the code). After that, because I debugged through the phone, took down the application, launched it again, and it all worked.

PS Wrote in Android Studio

  • one
    Most likely, the InstantRun function in the studio is simply not disabled - YuriySPb ♦
  • @Yuriy SPb, and where to turn it off? - Ivan
  • In the settings, build / execution there is something -> InstantRun - Yuriy SPb ♦