FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
learn-java/src/constructor/constructors.java at master · muzammyl/learn-java · GitHub
muzammyl
/
learn-java
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
3
Code
Pull requests
0
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
learn-java
/
src
/
constructor
/
constructors.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (40 loc) · 970 Bytes
Breadcrumbs
learn-java
/
src
/
constructor
/
constructors.java
Copy path
File metadata and controls
44 lines (40 loc) · 970 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
package
src
.
constructor
;
class
box2
{
double
width
,
height
,
depth
;
box2
() {
System
.
out
.
println
(
"Initializing Box..."
);
width
=
10
;
height
=
21
;
depth
=
31
;
}
double
volume
() {
return
width
*
height
*
depth
;
}
}
class
boxDemo2
{
public
static
void
main
(
String
[]
args
) {
box2
b21
=
new
box2
();
box2
b22
=
new
box2
();
System
.
out
.
println
(
"Volume of b21 is "
+
b21
.
volume
());
System
.
out
.
println
(
"Volume of b22 is "
+
b22
.
volume
());
}
}
class
box3
{
double
width
,
height
,
depth
;
box3
(
double
w
,
double
h
,
double
d
) {
width
=
w
;
height
=
h
;
depth
=
d
;
}
void
volume
() {
System
.
out
.
println
(
"Volume is "
+
width
*
height
*
depth
);
}
}
class
boxDemo3
{
public
static
void
main
(
String
[]
args
) {
box3
b31
=
new
box3
(
4
,
7
,
11
);
box3
b32
=
new
box3
(
21
,
54
,
11
);
b31
.
volume
();
b32
.
volume
();
}
}
Back
|
FazBrowse Home
|
New Git URL