Only Institute
to provide recording daily after class to students. you can practice whole day under faculty guidance. where test and mockup tests are taken regularly. provides all mobile nos of old students on website.

Collection all Assignment

Part I: Assignments on Arraylist with List

I. ArrayList with List:

1. It is a class uses a dynamic array for storing the elements.
2. It can contain duplicate elements.
3. Maintains insertion order. Technical
4. Not synchronized.
5. Random access because array works at the index.
6. Manipulation slows because a lot of shifting needs to be occurred.

Assignment 1: We have Student with age and location. Add multiple students in ArrayList and send it to other layer and other layer should able to iterate over it.
Java By Kiran

Here, 3 classes are firstly made. First is Student having age, location. Second is StudentArraylist for adding number of students in ArrayList. Third is StudentTest, having main method from where program is going to start initially..

Student Class



package com.arraylist1;

public class Student 
{
	int age;
	String location;
}
StudentArrayList


package com.arraylist1;
import java.util.ArrayList;

public class StudentArrayList 
{
		ArrayList al = newArrayList();
		
		public ArrayList showStudentInfo()
		{
			/*----------Adding First Student--------------------*/
			Student s1 = new Student();
			s1.age=25;
			s1.location="Pune";
			al.add(s1);
			
			
			/*----------Adding Second Student--------------------*/
			
			Student s2 = new Student();
			s2.age=26;
			s2.location="Mumbai";
			al.add(s2);
			
			
			/*----------Adding Third Student--------------------*/
			
			Student s3 = new Student();
			s3.age=24;
			s3.location="Delhi";
			al.add(s3);
			
			
			/*----------Adding Fourth Student--------------------*/
			
			Student s4 = new Student();
			s4.age=27;
			s4.location="Mumbai";
			al.add(s4);
						
			/*----------Adding Fifth Student--------------------*/
			
			Student s5 = new Student();
			s5.age=25;
			s5.location="Pune";
			al.add(s5);
			
			
			return al;
		}

	}


StudentTest.java



package com.arraylist1;
import java.util.ArrayList;
import java.util.Iterator;

public class StudentTest 
{
	public static void main(String[] args) {
		StudentArrayList sal = new StudentArrayList();
		ArrayList arraylist = sal.showStudentInfo();
		
		Iterator itr = arraylist.iterator();
		while(itr.hasNext())
		{
			Object obj = itr.next();
			Student stu = (Student)obj;
			System.out.println("Student Age is : " + stu.age);
			System.out.println("Student Location is : " + stu.location);
			System.out.println("****************************");
		}				
}
}




String s = new String("Test");