Skip to content

Commit c4180f4

Browse files
committed
Aggregation demo 2 updated
1 parent 85779b9 commit c4180f4

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

AggregationDemo2.java

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
1-
{
2-
"vendorId":"1",
3-
"userId":"1",
4-
"brands":
5-
[
6-
{
7-
"brandId":"",
8-
"productId":""
9-
},
10-
{
11-
12-
},
13-
{
14-
15-
},
16-
{
17-
18-
}
19-
]
1+
class Address{
2+
int hNo;
3+
String street;
4+
int pincode;
5+
String city;
6+
public Address(int hNo,String street,int pincode,String city){
7+
this.hNo = hNo;
8+
this.street = street;
9+
this.pincode = pincode;
10+
// this.city = city;
11+
}
12+
@Override
13+
public String toString(){
14+
return "Address{\n house no : "+hNo+",\n street : "+street+",\n pincode : "+pincode+",\n city : "+city+"}";
15+
}
16+
}
17+
class Student{
18+
int rn;
19+
String name;
20+
Address addr;
21+
public Student(int rn,String name,Address addr){
22+
this.rn = rn;
23+
this.name = name;
24+
this.addr = addr;
25+
}
26+
@Override
27+
public String toString(){
28+
return "Student{\n roll no :"+rn+",\n name : "+name+",\n address : "+addr+"}";
29+
}
30+
}
31+
class AggregationDemo2{
32+
public static void main(String[] args){
33+
Address addr = new Address(108,"A- Block",110033,"Delhi");
34+
Student s = new Student(1,"Tanishq",addr);
35+
System.out.println(s);
36+
}
37+
}

0 commit comments

Comments
 (0)