I'm trying to make a decimal to binary converter and this part of code is just a test sample. In this test program, I want to print out each element of the array and I just can't seem to make the program do that.
Here is my current code:
int[] nums = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
int dec;
int out = 0;
Scanner scan = new Scanner(System.in);
System.out.println("Type decimal number.");
dec = scan.nextInt();
for( nums[out] = nums[out] ; out < 16 ; out++ );
{
System.out.println(out + "\n");//I want to print each element just to test my code .
}
This is the output I get:
16
Where I should be getting this:
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Can someone please show me what I'm doing wrong?