FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs/Constructor/ConstEx1.java at master · crg-codes/Java-Programs · GitHub
crg-codes
/
Java-Programs
Public
forked from
divScorp/Java-Programs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programs
/
Constructor
/
ConstEx1.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (35 loc) · 921 Bytes
Breadcrumbs
Java-Programs
/
Constructor
/
ConstEx1.java
Copy path
File metadata and controls
46 lines (35 loc) · 921 Bytes
Raw
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
package
Constructor
;
public
class
ConstEx1
{
// if we won't provide any constructor compiler adds default constructor
// int this case, ConstEx1(){} , but if we provide any other constructor
// compiler won't add.
int
x
,
y
;
// no-argument constructor
ConstEx1
() {
getX
();
// we can call both static and non-static method from
// constructor
x
=
0
;
y
=
0
;
}
// Parameterized Constructor
ConstEx1
(
int
l
) {
x
=
y
=
l
;
getX
();
}
ConstEx1
(
int
l
,
int
m
) {
x
=
l
;
y
=
m
;
}
static
void
getX
() {
System
.
out
.
println
(
" You're inside method getX() "
);
// return x;
}
public
static
void
main
(
String
[]
args
) {
ConstEx1
c1
=
new
ConstEx1
();
System
.
out
.
println
(
"[C1]X= "
+
c1
.
x
+
" Y= "
+
c1
.
y
);
ConstEx1
c2
=
new
ConstEx1
(
20
);
ConstEx1
c3
=
new
ConstEx1
(
12
,
13
);
System
.
out
.
println
(
"[C2]X= "
+
c2
.
x
+
" Y= "
+
c2
.
y
);
System
.
out
.
println
(
"[C3]X= "
+
c3
.
x
+
" Y= "
+
c3
.
y
);
}
}
Back
|
FazBrowse Home
|
New Git URL