In this exercise you will create array of objects and perfor
Solution
 // simple program to insert data into array and search.
import java.util.*;
// student class definition
 class Student{
    int rollnumber;
    String name;
    Student(int rollnumber,String name){           // constructer with required parameters
        this.rollnumber=rollnumber;
        this.name = name;
    }
 }
 // definition of FindStudents class
 public class FindStudents{
    public static void main(String args[]){
        Student[] stu = new Student[10];
        Scanner sc = new Scanner(System.in);
        int i=0;
        // taking data from user for 10 students.
        for(;i<10;i++){
            System.out.println(\"Enter data for student no \"+(i+1)+ \":-\");
            System.out.print(\"\ Enter rollnumber:-\\t\");
            int rollnumber = sc.nextInt();
            System.out.print(\"\ Enter name:-\\t\");
            String name = sc.next();
            stu[i]= new Student(rollnumber,name);
            System.out.println(\"\ \\tInserted Data !!\ \");
        }
        // this will ask the user repeatedly which element he want to search and shows the results.
        while(true){
            System.out.println(\"\ Enter rollnumber you want to search. 999 for quit:-\\t\");
            int rollnumber = sc.nextInt();
            if(rollnumber == 999){
                break;
            }
            // calling FindStudent function
            Student temp = FindStudent(stu,rollnumber);
            if(temp.rollnumber == -1){
                System.out.println(\"\ \\t\"+temp.name+\"\ \");
                continue;
            }
            System.out.println(\"\ Student Found: \ \\trollnumber:-\\t\"+temp.rollnumber+\"name:-\\t\"+temp.name+\"\ \");
         }
    }
    // definition of FindStudent definition
    public static Student FindStudent(Student students[], int rollnumber){
        int length= students.length;
        Student temp;
        // over students array checking for required element.
        for(int i=0;i<length;i++){
            if(students[i].rollnumber == rollnumber){       // if element found
                temp = students[i];
                return temp;               // return element
            }
        }
        temp = new Student(-1,\"rollnumber_not_found\"); // if not found return element with false indication message.
        return temp;
    }
 }


