-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2_Association_Many to Many
More file actions
44 lines (38 loc) · 969 Bytes
/
Copy path2_Association_Many to Many
File metadata and controls
44 lines (38 loc) · 969 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
41
42
43
44
//Many to Many relationship
import java.io.*;
class Bank //Create class Bank
{
private String name;
Bank(String name)
{
this.name = name; //this keyword refers to current instance itself
}
public String getBankName()
{
return this.name;
}
}
class Employee
{
private String name;
Employee(String name)
{
this.name = name;
}
public String getEmployeeName()
{
return this.name;
}
}
class Main
{
public static void main(String[] args)
{
Bank bank1 = new Bank("RBI");
Bank bank2 = new Bank("ICICI"); //Multiple banks
Employee emp1 = new Employee("Smart");
Employee emp2 = new Employee("VIT"); //Multiple employees
System.out.println(emp1.getEmployeeName() + " is employee of " + bank1.getBankName());
System.out.println(emp2.getEmployeeName() + " is employee of " + bank2.getBankName());
}
}