קליטה של 2 שדות של סטודנטים (מחרוזות בלבד) והדפסתם. רק להריץ באקליפס ולבדוק...תודה מראש
קוד:import java.io.BufferedReader; import java.io.InputStreamReader; class Student { String Name ,Fname; //, Address ,Zip ,ID , Phone; InputStreamReader input = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(input); public Student () { Name=""; Fname=""; } public void setStudent () { System.out.println("Enter student's name"); try {Student.Name = reader.readLine();}//ERROR catch(Exception e){} System.out.println("Enter student's family name"); try {Student.Fname = reader.readLine();}//ERROR catch(Exception e){} } public void printStudent() { System.out.println("Student name is: " + Name ); System.out.println("Student family name is: " + Fname ); } }/*Student*/ //ERROR: Cannot make a static reference to the non-static field Student.Nameקוד:public class StudentsReg { Student student[]; public void main(String[] args) { int i; for (i=0;i<1;i++) { student[i]= new Student(); student[i].setStudent(); student[i].printStudent(); } } }



ציטוט ההודעה