當前位置:編程學習大全網 - 網站源碼 - java定義壹個學生類,其中包含姓名、年齡、成績的屬性,之後由鍵盤輸入學生的內容,並將內容保存在文件

java定義壹個學生類,其中包含姓名、年齡、成績的屬性,之後由鍵盤輸入學生的內容,並將內容保存在文件

Class Student{

private String stuName;

private short stuAge;

private double stuScore;

//get,set方法...略

//toString()將所有信息返回

}

Class test{

public static void main(String args[]) throws Exception{

//根據反射機制獲取Student類

Class.forName("Student.class");

//鍵盤輸入可以用System.in

//將輸入的值設置到Student 對象中

//由於是純文本可以用BufferdWriter類寫到壹個文件中

}

}

  • 上一篇:如何實現用戶登錄,用戶名,密碼驗證,Oracle數據庫。AJAX+JQuery或者JSP都可以。查找特定代碼或示例。
  • 下一篇:如何開壹家麻將室吸引人?
  • copyright 2024編程學習大全網