Reputation: 21
import myPack.*;
public class HelloWorld{
public static void main(String args[])
{
int a=Integer.parseInt(args[0]);
Factorial f= new Factorial();
int d = f.fact(a);
System.out.println("Factorial of " +a+ " is : " +d);
}
}
package myPack;
public class Factorial
{
public int fact(int b)
{
int c=1;
for(int i=b;i>0;i--)
{
c=c*i;
}
return c;
}
}
E:\Packages>javac HelloWorld.java
HelloWorld.java:7: error: cannot access Factorial
Factorial f= new Factorial();
^
bad source file: .\Factorial.java
file does not contain class Factorial
Please remove or make sure it appears in the correct subdirectory of the sou
rcepath.
1 error
Upvotes: 2
Views: 61