Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
70 lines (68 loc) · 1.77 KB

File metadata and controls

70 lines (68 loc) · 1.77 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package chapter08;
/* VectorOperationEx1.java */
/* Example of Vector Operations using Class and Objects */
import java.util.*;
class Student{
long Roll;
String Name;
double Mark;
Student NextStudent;
static Student StudentList;
static void paint()
{
Student S = StudentList;
if(S == null)
System.out.println("There is no student in the list");
else
do{
System.out.println(S);
S = S.NextStudent;
}while(S!=null);
}
Student (long Roll , String Name , double Mark)
{
this.Roll = Roll;
this.Name = Name;
this.Mark = Mark;
this.NextStudent = StudentList;
StudentList = this;
}
public String toString(){
return new String(Roll + "\t" +Name + "\t" +Mark + "\n");
}
}
public class VectorOperationEx1 {
public static void main(String args[])
{
Vector V = new Vector();
V.addElement(new Student(18, "Masud", 75.5));
V.addElement(new Student(51, "Monira",85.0));
System.out.println("List of Students : ");
System.out.println("Roll: \t Name: \t Mark: ");
for (int i=0; i<3; i++)
{
System.out.print(V.elementAt(i));
// displaying i-th Element.
}
V.insertElementAt(new Student(21, "Mira",80), 1);
//Inserting a new Element at Position 1
System.out.println("\nAfter Inserting Element at Position 1 : ");
System.out.println("List of Students : ");
System.out.println("Roll: \t Name: \t Mark: ");
// displaying Modified Vector Elements.
for (int i=0; i<3; i++)
{
System.out.print(V.elementAt(i));
// displaying i-th Element.
}
V.removeElementAt(0);
//Removing Element of Position 0
System.out.println("\nAfter Removing Element of Position 0 : ");
System.out.println("List of Students : ");
System.out.println("Roll: \t Name: \t Mark: ");
for (int i=0; i<3; i++)
{
System.out.print(V.elementAt(i)); // displaying i-th Element.
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.