Stuck in main function. countDigit function is right but code is showing error

import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int d = sc.nextInt();
System.out.println(countDigit(n,d));
}

public static int countDigit(int n,int d){
    int count = 0;
	while(n !=0){
		int rem = n%10;
		if(rem == d){
			count++;
		}
		n = n/10;


	}
}

}

@discobot in the countDigit Function you are not returning anything but since you have specified int as return type you need to return an int.
correct CountDigit Funciton // Return count;

public static int countDigit(int n,int d){
    int count = 0;
	while(n !=0){
		int rem = n%10;
		if(rem == d){
			count++;
		}
		n = n/10;

	}
return count;
}

Hi! To find out what I can do, say @discobot display help.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.