I try to make a android application, the goal is that player will play against te computer. First player will fill in what kind of a digit(possibilities are 3 or 4 digit).
Let's say player choose 3 digit. Than computer generate a digit that every nummer may only use once in the digit. Like 021, 236, 750 ... Than player will create also 3 digit. Than player will try to guess computer nummer an computer will try to find player nummer. i have tried something like that;
public static void main(String[] args) {
ArrayList<String> fiNum = new ArrayList<String>();
ArrayList<String> cijfer = new ArrayList<String>();
cijfer.add("0");
cijfer.add("1");
cijfer.add("2");
cijfer.add("3");
cijfer.add("4");
cijfer.add("5");
cijfer.add("6");
cijfer.add("7");
cijfer.add("8");
cijfer.add("9");
System.out.println("Please enter digit length ");
Scanner nummerOfChoise = new Scanner(System.in);
String cooiseresult = nummerOfChoise.nextLine();
int cc = Integer.parseInt(cooiseresult);
for (int i = 0; i < cc; i++) {
int getal = (int) (Math.random() * cijfer.size());
fiNum.add(cijfer.get(getal));
cijfer.remove(getal);
}
System.out.print(fiNum);
}
If i want to print the nummer it prints something like
Please enter digit length
3
[3, 9, 1]
my question is what is the best approach to convert this array to integer or string and how can i do that.
Thank you.