Storing Integer value as A Character Java -
i tried in previous stack overflow questions not find similar.
i want store integer value char variable integer value stored in variable.
char[] ch1 = (binary1.tostring()).tochararray(); char[] ch2 = binary2.tostring().tochararray(); if (ch1.length >= ch2.length) { char[] ch = new char[ch1.length]; int j = 0; int num1; int num2; int num3; (int = 0; < ch1.length; i++) { if (j == ch2.length - 1) j = 0; num1 = character.getnumericvalue(ch1[i]); num2 = character.getnumericvalue(ch2[j]); num3 = num1 ^ num2; ch[i] = (char) num3; j++; } string str = new string(ch); return str; }
here happening getting null values in many cases. tried in character class not find function.
if there way please tell. in advance.
edit : need store either 0 or 1
edit : ch1[] & ch2[] ar of char type
edit : got temporary solution problem wider concept how should type cast integer char if size same , when getting null values.
you can do
char ch = num3 == 0 ? '0' : '1';