Write a java program to take a number and return list of its digits

Write a java program to take a number and return list of its digits. Take a number and return a list of its digits with a Java program. Take a number and return a list of its digits with a Java program. As an input, you can use any integer number. The amount of digits in the given input is then counted. The given number, along with its length, is handed to the other function, which returns all of the digits of the given number via modulus and division operations.

import java.util.Scanner;
public class Main
{
int[] digits(int m,int l)
{
int x[] = new int[l];
int i = 0;
while(m > 0)
{
x[i] = m % 10;
m = m / 10;
i++;
}
return x;
}
public static void main(String[] args)
{
int counter = 0, n, m;
Scanner s = new Scanner(System.in);
System.out.print("Enter any number:");
n = s.nextInt();
m = n;
while(n > 0)
{
n =n / 10;
counter++;
}
Main obj=new Main();
int a[]=obj.digits(m, counter);
System.out.print("Digits:");
for(int i = a.length-1; i >= 0; i--)
{
System.out.print(a[i]+" ");
}
}
}

Enter any number: 45
Digits:4 5