ii m getting error message "class ,interface or enum expected.can anybody help me please thanks.."

import javax.swing.*;
import java.util.*;

public class StudentBook

{

ArrayList students;

public StudentBook()
{

students=new ArrayList();

}

public void addStudent()

{

String name=JOptionPane.showInputDialog("Enter the name of the Student");

String rNum=JOptionPane.showInputDialog("Enter the Roll Number of the Student");

String pNum=JOptionPane.showInputDialog("Enter the Phone Number of the Student");

String stProgram=JOptionPane.showInputDialog("Enter the name of the Study Program");

String stStatus=JOptionPane.showInputDialog("Enter the Status of the Student");

StudentInfo s=new StudentInfo(name,rNum,pNum,stProgram,stStatus);
students.add(s);

}

public void searchStudent(String r)

{

for(int i=0;i<students.size();i++)

{

StudentInfo s=(StudentInfo)students.get(i);

if(r.equals(s.rollNum))

{
s.print();
}
else

{

JOptionPane.showMessageDialog("Student not found for Roll Number" + r);

}

}
}

//to delete the Student

public void deleteStudent(String r)

{

for(int i=0;i<students.size();i++)

{

StudentInfo s=(StudentInfo)students.get(i);

if(r.equals(s.rollNum))

{
s.remove(i);
}
else

{

JOptionPane.showMessageDialog("Student not found for deletion having roll number" +

r);

}

}
}
}
}

you have too many or too little '}' & '{' but i fixed it quickly using my IDE, and the way you called the JOptionPane methods was wrong:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package studentbook;

import java.util.ArrayList;
import javax.swing.JOptionPane;

public class StudentBook {

    ArrayList students;

    public StudentBook() {

        students = new ArrayList();

    }

    public void addStudent() {

        String name = JOptionPane.showInputDialog("Enter the name of the Student");

        String rNum = JOptionPane.showInputDialog("Enter the Roll Number of the Student");

        String pNum = JOptionPane.showInputDialog("Enter the Phone Number of the Student");

        String stProgram = JOptionPane.showInputDialog("Enter the name of the Study Program");

        String stStatus = JOptionPane.showInputDialog("Enter the Status of the Student");

        StudentInfo s = new StudentInfo(name, rNum, pNum, stProgram, stStatus);
        students.add(s);

    }

    public void searchStudent(String r) {

        for (int i = 0; i < students.size(); i++) {

            StudentInfo s = (StudentInfo) students.get(i);

            if (r.equals(s.rollNum)) {
                s.print();
            } else {

                JOptionPane.showMessageDialog(null, "Student not found for Roll Number" + r);

            }

        }
    }

//to delete the Student
    public void deleteStudent(String r) {

        for (int i = 0; i < students.size(); i++) {

            StudentInfo s = (StudentInfo) students.get(i);

            if (r.equals(s.rollNum)) {
                s.remove(i);
            } else {

                JOptionPane.showMessageDialog(null, "Student not found for deletion having roll number" + r);

            }

        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.