source file name:  FactDemo.java 

import java.io.*;

class A

{

int y;

public A(int n)

{

y=n;

}

public void disp()

{

int f=1;

while(y>0)

{

f=f*y;

y--;

}

System.out.println("Factorial value of given number is:="+f);

}

}

class FactDemo

{

public static void main(String as[])

{

int n=1;

System.out.println("enter value:");

try{

DataInputStream dis=new DataInputStream(System.in);

String s=dis.readLine();

n=Integer.parseInt(s);

}

catch(Exception e){System.out.println(e);}

A ob=new A(n);

ob.disp();

}

}

output:

D:\JavaPrograms\Constructors>javac FactDemo.java

D:\JavaPrograms\Constructors>java FactDemo
enter value:
6
Factorial value of given number is:=720

D:\JavaPrograms\Constructors>java FactDemo
enter value:
9
Factorial value of given number is:=362880