Digit Frequency

Given a number the task is to find the frequency of all digits present in that number.

Example: Consider a number 256225. Here 2 is present three times, 5 is present two times and 6 is present one time.

Java
import java.util.*;
public class DigitFrequency
{
    public static void main(String args[])
    {
        int n=0,r=0,frequency=0,nCopy=0;
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter a number: ");
        n=sc.nextInt();
        nCopy=n;
        System.out.println("Digit\tFrequency");
        for(int i=0;i<=9;i++)
        {
            n=nCopy;
            while(n>0)
            {
                r=n%10;
                if(r==i)
                {
                    frequency++;
                }
                n=n/10;
            }
            if(frequency>0)
            {
                System.out.println(i+"\t"+frequency);
            }
            frequency=0;
        }
    }
}
Java