-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStudentMain.java
More file actions
45 lines (45 loc) · 1.05 KB
/
StudentMain.java
File metadata and controls
45 lines (45 loc) · 1.05 KB
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
class Student
{
String name,address;
int age;
Student()
{
name ="unknown";
age=0;
address="not available";
}
public void setInfo(String name,int age)
{
this.name=name;
this.age=age;
}
public void setInfo(String name,int age,String address)
{
this.name=name;
this.age=age;
this.address=address;
}
}
class StudentMain
{
public static void main(String[] args)
{
Student obj[]=new Student[10];
for (int i=0;i<10;i++)
{
obj[i]=new Student();
}
obj[2].setInfo("Jayash",19);
obj[5].setInfo("Amit",19,"Kosi");
obj[7].setInfo("Anamika",19,"Chhata");
obj[9].setInfo("Mohak",22);
obj[1].setInfo("Mradul",19,"Mathura");
obj[0].setInfo("Garima",19,"Radhapuram");
obj[4].setInfo("Priyanshi",18);
obj[3].setInfo("Vibhu",20);
for (int i=0;i<10;i++)
{
System.out.println(obj[i].name+" "+obj[i].age+" "+obj[i].address);
}
}
}