i am working on an assignment, where i take a number from the whole number (so 1 from 122) and check if it divisible or not. i do this for every number. if every one is divisible, it returns true. if not, return false. i have been working on this, and for some reason, when I attempt to get the first one, i am getting the wrong data. here is my code:

public class dividesSelf { static boolean divide(int n) { int x = 0; int y; int z; String number = Integer.toString(n); for(int i = 0; i<number.length(); i++) { x = (int)number.charAt(i); } System.out.println(x); return false; } public static void main(String[] args) { System.out.println(divide(122)); } }