Java Reference
In-Depth Information
System
.
out
.
println
(
c
+
" {"
);
Field fields
[] =
c
.
getDeclaredFields
();
for
for
(
Field f
:
fields
) {
final
final
Annotation
[]
fldAnnotations
=
f
.
getAnnotations
();
for
for
(
Annotation a
:
fldAnnotations
) {
System
.
out
.
println
(
a
);
}
iif
(!
Modifier
.
isPrivate
(
f
.
getModifiers
()))
System
.
out
.
println
(
"\t"
+
f
+
";"
);
}
Constructor
<?
extends
extends
Object
>[]
constructors
=
c
.
getConstructors
();
for
for
(
Constructor
<?
extends
extends
Object
>
con
:
constructors
) {
System
.
out
.
println
(
"\t"
+
con
+
";"
);
}
Method methods
[] =
c
.
getDeclaredMethods
();
for
for
(
Method m
:
methods
) {
final
final
Annotation
[]
methodAnnotations
=
m
.
getAnnotations
();
for
for
(
Annotation a
:
methodAnnotations
) {
System
.
out
.
println
(
a
);
}
iif
(!
Modifier
.
isPrivate
(
m
.
getModifiers
())) {
System
.
out
.
println
(
"\t"
+
m
+
";"
);
}
}
System
.
out
.
println
(
"}"
);
}
catch
catch
(
ClassNotFoundException e
) {
System
.
err
.
println
(
"Error: Class "
+
className
+
" not found!"
);
}
catch
catch
(
Exception e
) {
System
.
err
.
println
(
"JavaP Error: "
+
e
);
}
}
}
Listing Classes in a Package
Problem
You want to get a list of all the classes in a package.