-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraylist.java
More file actions
40 lines (35 loc) · 819 Bytes
/
Arraylist.java
File metadata and controls
40 lines (35 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package lab8;
import java.util.*;
class Student
{
int rollno;
String name;
int age;
Student(int rollno,String name,int age)
{
this.rollno=rollno;
this.name=name;
this.age=age;
}
}
class TestStudent
{
public static void main(String args[])
{
Student s1=new Student(10,"mansi",24);
Student s2=new Student(05,"jeel",20);
Student s3=new Student(15,"divya",23);
Student s4=new Student(07,"jil",19);
Student s5=new Student(13,"Tulsi",15);
Student s6=new Student(04,"vaibhavi",20);
ArrayList<Student> al=new ArrayList<Student>();
al.add(s1);
al.add(s2);
al.add(s3);
al.add(s4);
al.add(s5);
al.add(s6);
for(Student st:al)
System.out.println(st.rollno+" "+st.name+" " + st.age);
}
}