When I compile, I get this error for some reason.
C:\Java\Assignment\Factorial>javac SampleOutputPanel.java
SampleOutputPanel.java:12: cannot find symbol
symbol : constructor Factorial(int)
location: class Factorial
f = new Factorial (5);
^
1 error
My code is as follows.
Factorial.java
import javax.swing.*; import java.awt.*; public class Factorial { static int currentVal; public static int Factorial (int n) { if (n == 0) return 1; currentVal = n * Factorial (n - 1); System.out.println (currentVal); return (currentVal); } }
SampleOutputPanel.java
import java.awt.*; import java.awt.event.*; import javax.swing.*; class SampleOutputPanel extends JPanel { Factorial f; public SampleOutputPanel () { f = new Factorial (5); setPreferredSize (new Dimension (496, 120)); setBorder (BorderFactory.createTitledBorder ("Sample Output")); add (new JLabel ("Output" + f)); } }
Please help out, thanks!