i have 2 number inputs 1010 212 i want put these 2 different arrays ([1 0 1 0] , [2 1 2]) this code import java.io.*; import java.util.*; public class solution { public static void main(string[] args) { int array[] = new int[8]; int array2[] = new int[8]; int = 0; scanner getnumber = new scanner(system.in); { array[i] = getnumber.nextint(); i++; } while(getnumber.hasnextint()); system.out.println(arrays.tostring(array)); } } but output [1010, 212, 0, 0, 0, 0, 0, 0] (i put 8 generic array length because java compiler forced initialize each array) you need store numbers first initialize arrays based on length of number. can length turning string. once left number , empty array, can split integer array of digits number of ways. int[] array, array2; scanner in = new scanner(system.in); int a, b; = in.nextint(); b = in.nextint(); array = new int[integer.tostring(a...
Comments
Post a Comment