Make it a class level variable - not a public static member.
Ezzaral
Posting Genius
15,985 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
public class Program1 {
Scanner scanner = null;
public Program1(){
try {
scanner = new Scanner(new File("t.txt"));
} catch (FileNotFoundException fe){
fe.printStackTrace();
}
}
public static void main(String[] args) {
}
}
Ezzaral
Posting Genius
15,985 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847