Answer the question
In order to leave comments, you need to log in
Nothing happens, what should I do?
package translatorInt;
import java.util.*;
import java.io.*;
public class translatorInt {
public static Scanner in = new Scanner(System.in);
public static PrintStream out = System.out;
public static void main(String[] args) {
numberInt(5,8);
}
public static void numberInt(int number, int sizeArray) {
int[] deviden = new int[sizeArray-1];
int[] bNumber = new int[sizeArray];
bNumber[sizeArray-1] = number % 2;
deviden[0] = number /2;
for(int i = 1; i < deviden.length; i++) {
for(int x = bNumber.length-2;x != 0;x--) {
bNumber[x] = deviden[i-1] % 2;
deviden[i] = deviden[i=1] / 2;
}
}
for (int v : bNumber)
out.print(v);
}
}
I start nothing happens, why? Point out the error
Answer the question
In order to leave comments, you need to log in
deviden[i] = deviden[i=1] / 2;
here i is equal to 1, so you don't need to do this, maybe it's a typo.
Because of this equation, the outer for is infinite. The program runs, but it cannot exit the loop. Look in the task manager - there will be as many Java processes running as many times you called the program.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question