FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-basics/core-java/basics/JVMDemo01.java at patch-1 · CodeForHunger/java-basics · GitHub
CodeForHunger
/
java-basics
Public
forked from
learning-zone/java-basics
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-basics
/
core-java
/
basics
/
JVMDemo01.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (30 loc) · 1020 Bytes
Breadcrumbs
java-basics
/
core-java
/
basics
/
JVMDemo01.java
Copy path
File metadata and controls
53 lines (30 loc) · 1020 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
package
basics
;
import
java
.
lang
.
reflect
.
Field
;
import
java
.
lang
.
reflect
.
Method
;
public
class
JVMDemo01
{
public
static
void
main
(
String
[]
args
) {
Employee
s1
=
new
Employee
();
// Getting hold of class object created by JVM
Class
c1
=
s1
.
getClass
();
System
.
out
.
println
(
"Class Name: "
+
c1
.
getName
());
// getting all methods in array
Method
m
[] =
c1
.
getDeclaredMethods
();
for
(
Method
method
:
m
)
System
.
out
.
println
(
"Method Name: "
+
method
.
getName
());
// getting all fields in array
Field
f
[] =
c1
.
getDeclaredFields
();
for
(
Field
field
:
f
)
System
.
out
.
println
(
"Field Name: "
+
field
.
getName
());
}
}
// A Sample class whose information is fetched above using its Class Object.
class
Employee
{
private
String
name
;
private
int
emp_id
;
public
String
getName
() {
return
name
; }
public
void
setName
(
String
name
) {
this
.
name
=
name
; }
public
int
getEmp_id
() {
return
emp_id
; }
public
void
setEmp_id
(
int
emp_id
) {
this
.
emp_id
=
emp_id
;
}
}
Back
|
FazBrowse Home
|
New Git URL