Java Programming Assignment:1225347

 In order to complete this assignment, the concept of inheritance and array lists are used.  For storing the array of objects, the array list is utilized.  The ArrayList belongs to the collection framework available in java which comes under the java.util package.  Through this package we can declare and use dynamic arrays in programs. Even though these collections are comparatively slower than standard arrays.  Here, it can be stated that the array lists are very helpful in the applications where too many manipulations on the declared array is required.

ArrayList mainly inherits AbstractList class of java. Whenever used in the program it implements List interface and executed in the program in order to store and manipulate the data in the array. Even though the ArrayLists can be initialized with a specific size, but the size and required memory can be increased or decreased whenever collection of data or objects are increased or decreased depending upon the addition and removal of data from collection. The ArrayList are also helpful in reducing required time for computations as it allows random access to the list of objects.  Here, it is important to mention that ArrayList objects are not to be used for   the storage and manipulation of the primitive data types such as int, double, char, string and so on.  In order to do so it is important to use a wrapper class.  While developing the student details program in Java, it is found that the ArrayList are capable of storing duplicate elements, preserves insertion order of the objects/elements and non-synchronized. In case of  the multi-threaded environment, it is possible that too many threads  will try to  access or modify an specific ArrayList simultaneously in that scenario final result becomes non-deterministic due to the non-synchronized nature.

Student class

package pkg1225347;

import java.util.Scanner;

/**

 *

 * @author user

 */

public class studentclass {

    String Name;

int id;

String loc;

        double marks;

        String subject;

public studentclass(String Name, int id, String loc, double marks, String subject) {

this.Name=Name;

this.id=id;

this.loc=loc;

                this.marks=marks;

                this.subject=subject;

}

    public studentclass() {

    }

public String toString(){

return “(“+Name+”,”+id+”,”+loc+”,”+marks+”,”+subject+”)”;

        }

    public void search(studentclass stu, String name)

    {

        if(stu.Name==name){

            System.out.println(“The Student is in list”);

        }

        else

        {

            System.out.println(“The Student Record not found”);

        }

    }

     public void update(studentclass stu, String name)

    {

        if(stu.Name==name){

            Scanner in = new Scanner(System.in);

            System.out.println(“Enter new value for marks”);

            String input = in.nextLine();

            stu.marks=Integer.parseInt( input );

        }

        else

        {

            System.out.println(“No record found”);

        }

    }

}

Main class

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

package pkg1225347;

import java.util.ArrayList;

/**

 *

 * @author user

 */

public class Main {

    /**

     * @param args the command line arguments

     */

    public static void main(String[] args) {

        // TODO code application logic here

        studentclass sm=new studentclass();

        ArrayList arlist=new ArrayList();

studentclass s0=new studentclass(“John”,101,”Michigan”,25.5,”History”);

studentclass s01=new studentclass(“Jacob”,102,”Bangalore”,40,”Mathematics”);

studentclass s02=new studentclass(“Kate”,103,”Detroit”,45.8,”Biology”);

studentclass s03=new studentclass(“Rolland”,104,”California”,15.2,”Physics”);

studentclass s04=new studentclass(“Timothy”,105,”Philladelphia”,38.8,”calculas”);

arlist.add(s0);

arlist.add(s01);

arlist.add(s02);

arlist.add(s03);

arlist.add(s04);

        arlist.forEach((stut) -> {

            System.out.println(stut.toString());

        });

        sm.search(s01, “John”);

        sm.update(s04, “Kate”);

        arlist.forEach((stut) -> {

            System.out.println(stut.toString());

        });

    }

}