⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getstudentrecord.java

📁 java记录成绩册
💻 JAVA
字号:
import java.io.*;
public class GetStudentRecord {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		StudentRecord[] oneArray=new StudentRecord[3];
		oneArray[0]=new StudentRecord(10,"Mike","male",90,56,78,99,34,12,4,68,100,12,6);
		oneArray[1]=new StudentRecord(11,"Bruin","male",95,97,98,99,96,100,99,90,99,100,10);
		oneArray[2]=new StudentRecord(12,"Andy","female",86,56,78,89,90,99,67,12,45,100,7);
		try{
			ObjectOutputStream outputStream=new ObjectOutputStream(new FileOutputStream("array.file"));
			outputStream.writeObject(oneArray);
			outputStream.close();
		}
		catch(IOException e){
			System.out.println("Error writing to array.file.");
			System.exit(0);
		}
		System.out.println("The students' record has been saved.");
		System.out.println("Now you can check the data.");
		StudentRecord[] anotherArray=new StudentRecord[3];
		try{
			ObjectInputStream inputStream=new ObjectInputStream(new FileInputStream("array.file"));
			anotherArray=(StudentRecord[])inputStream.readObject();
			inputStream.close();
		}
		catch(Exception e){
			System.out.println("Error reading from array.file.");
			System.exit(0);
		}
		System.out.println("Please enter the number of the student.");
		int m=SavitchIn.readInt();
		for(int i=0;i<3;i++){
			if(m==anotherArray[i].number)
				System.out.println(anotherArray[i]);
		}
		if((m!=anotherArray[0].number)&&(m!=anotherArray[1].number)&&(m!=anotherArray[2].number)){
			System.out.println("The number doesn't exist.");
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -