我需要在此文件中打印最大和最小数字...我尝试了所有方法,但似乎无法使其正常工作。我是初学者请帮忙
public class Banck {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
System.out.println("Welcome to JEEEZBANK");
final int NUM_TO_QUIT = -99;
String userin ;
int num;
System.out.println("Enter a file ending with .txt");
Scanner scan = new Scanner(System.in);
userin = scan.nextLine();
// create file
PrintWriter file = new PrintWriter(userin);
for(int i=1; i<5; i++){
System.out.println("enter first number "+i +" or -99 to quit");
num = scan.nextInt();
if(num == NUM_TO_QUIT){
System.out.println("bye");
System.exit(0);
}
file.println(num);
}
file.close();
// read file and print smallest and biggest number
Scanner read = new Scanner(file);
while(read.hasNext()){
// add the numbers to the array
int[] numlist = {num};
// print the biggest and smallest number inside the numlist array.
}
}
}