Check out example codes for "how to make factorial in java". It will help you in understanding the concepts better.

Code Example 1

class fact{
	static int fac(int n){
		int ans =1;
		for(int i=1; i<=n; i++){
			ans = ans*i;
		}
		return ans;
	}

	public static void main (String[] args){
		int f = 5;
		System.out.println(fac(f));
	}
}

Learn ReactJs, React Native from akashmittal.com