Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How java decomposes int into integer arrays
How java decomposes int into integer arrays
Import java.util. *;

Teaching materials for public courses

{

Public static void main(String args[])

{

System.out.println ("Please enter an integer:");

Scanner sc = new scanner (system. in);

int n = sc . nextint();

int[]y = get array(n);

}

public static int[]get array(int n){

Integer N = new integer (n);

char[] s=N.toString()。 toCharArray();

int[]y = new int[s . length];

for(int I = 0; I<s. Length; i++)

{

y[I]=(s[I]-48);

//system . out . println(y[I]);

}

Returns y;

}

}

Let's stop here. Don't scold me if you feel bad. The code has been debugged, and the function has been realized anyway. . . . . . . . ! ! !