کلاس Main در زمان کامپایل خطای cannot find symbol برای متغییر bottom می دهد:
package javatest01;
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
Kasr k = new Kasr(3, 7);
k.add(2, 3);
JOptionPane.showMessageDialog(null, "top is = " + k.top);
JOptionPane.showMessageDialog(null, "bottom is = " + bottom);
}
}
package javatest01;
public class Kasr {
int top;
int bottom;
public Kasr(int t, int b) {
top = t;
bottom = b;
}
void add(int a, int b) {
top = top * b + a * bottom;
bottom = b * bottom;
}
}