-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.java
45 lines (36 loc) · 866 Bytes
/
Main.java
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
public class Main
{
// username variale.
private String userName;
// Default contructor.
Main()
{
userName = "";
}
// Overloaded constructor.
Main(String userName)
{
this.userName = userName;
}
// accessor or getter method.
public String getUserName()
{
return this.userName;
}
// mutator or setter method.
public void setUserName(String userName)
{
this.userName = userName;
}
// main drivan function.
public static void main(String[] args)
{
// creating first user.
var user1 = new Main();
user1.setUserName("Muhammad Naveed");
System.out.println(user1.getUserName());
// creating second user.
var user2 = new Main("M Naveed");
System.out.println(user2.getUserName());
}
}