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.

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:"); 



    JOptionPane.showMessageDialog(null, "Student Name is: "+s.getName() + " "+t.getName());        

    firstName= JOptionPane.showInputDialog("Enter first name:");


    JOptionPane.showMessageDialog(null, "Student Name is: "+s.getName()+ " " +t.getName());  




public class Student{

    private String firstName;
    private String lastName;
    private String studentID;//attribute

    public void setStudent (String firstName,String lastName,String Student){    

    public String getName(){
        return firstName;

    public void setfirstName(String newfirstName){

Edited 3 Years Ago by pyTony: fixed formatting


what do you think will happen?
Have you even tried it?

And no, we're not going to read your assignment that you attached as a word document.

If something doesn't work as you think it should, tell us what it does, what it should do, and we may be able to tell you where you made a mistake.

This question has already been answered. Start a new discussion instead.