fork download
  1. public class FactorialCalculator
  2. {
  3. public long factorial( long number )
  4. {
  5. if(number <= 1)
  6. return 1;
  7. else
  8. return number * factorial( number - 1);
  9. }
  10.  
  11. public void displayFactorials()
  12. {
  13. for ( int counter = 0; counter <= 10; counter++)
  14. System.out.printf( "%d! = %d\n", counter, factorial(counter));
  15. }
  16.  
  17. }
  18.  
  19. public class FactorialTest
  20. {
  21. public static void main( String args[])
  22. {
  23. FactorialCalculator factorialCalculator = new FactorialCalculator();
  24. factorialCalculator.displayFactorials();
  25. }
  26.  
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: class FactorialCalculator is public, should be declared in a file named FactorialCalculator.java
public class FactorialCalculator
       ^
Main.java:19: class FactorialTest is public, should be declared in a file named FactorialTest.java
public class FactorialTest
       ^
2 errors
stdout
Standard output is empty