0
Array
Im trying to write a code that accepts 8 digits into an array & then calls a method to display each digit in the array. Each time I run it, it displays the incorrect values from the array. Any help would be great. Thx! https://code.sololearn.com/cmWRPg6MrY0I/?ref=app
8 Respostas
0
thx!
0
thank you
- 1
use println() rather
System.out.println("Enter a Digit>>> "); // println() for print to new line
// i instead 0 because you fill all array not only first element
newData[i] = input.nextInt();
++newData[i]; // same i instead 0
// same [i] instead [0] because you want print all elements not only first 8x
for(int i = 0; i < newData.length; ++i)
System.out.print(newData[i]);
then other System.out.print(newData[..]); after for() you can delete