this the my first assignment given by my lecturer.
i've tried to do it and manage to compile..but the problem is i got confused on how this program execute?
is it line by line like c++?
can someone show me the sequence on how my program being executed and maybe doing some correction on it??
The question is in the attachment file.
//TESTSTUDENT
import javax.swing.JOptionPane;
public class TestStudent {
public static void main(String[] args) {
String firstName,lastName;
Student s = new Student();
Student t = new Student();
firstName= JOptionPane.showInputDialog("Enter first name:");
lastName= JOptionPane.showInputDialog("Enter last name:");
s.setfirstName(firstName);
t.setfirstName(lastName);
JOptionPane.showMessageDialog(null, "Student Name is: "+s.getName() + " "+t.getName());
firstName= JOptionPane.showInputDialog("Enter first name:");
s.setfirstName(firstName);
JOptionPane.showMessageDialog(null, "Student Name is: "+s.getName()+ " " +t.getName());
}
}
//STUDENT
public class Student{
private String firstName;
private String lastName;
private String studentID;//attribute
//constructor
public void setStudent (String firstName,String lastName,String Student){
}
//method
public String getName(){
return firstName;
}
public void setfirstName(String newfirstName){
firstName=newfirstName;
}
}