i hava a variable I want too use in 2 class. Must I declare it as static variable? can it be instance variable?
public class Text extends JFrame implements ActionListener{
JTextArea t;
String s;
}
I want to use s in another class. Must I declare it as static variable? Is it possible to declare it as instance variable?
You don’t decide on whether a variable is static or not based on how it will be used. If it’s common to all the
Textinstances, then it must be static. If each Text instance has its owns(whatever this poorly chosen name might in fact represent), then it must be an instance variable.