Commit bc2b4d8
committed
feat: Add ArrayListDemo7 to explore constructors
and methods via reflection
This demo showcases how to use Java
Reflection API to inspect the
internal structure of the ArrayList class.
Key highlights:
• Obtains the Class object for java.util.ArrayList using ArrayList.class.
• Retrieves all declared constructors with getDeclaredConstructors().
• Retrieves all declared methods with getDeclaredMethods().
• Iterates over constructors and methods, printing their names.
Why this is useful:
• Demonstrates reflection capabilities for runtime class inspection.
• Helps understand how many constructors and methods exist inside
core library classes like ArrayList.
• Useful for debugging, framework design,
and meta-programming tasks
where behavior adapts based on runtime
class analysis.
Output:
- Prints the list of all constructor
signatures of ArrayList.
- Prints the names of all methods (public,
protected, private, and package-private declared within ArrayList).
Signed-off-by: https://github.com/Someshdiwan <someshdiwan369@gmail.com>1 parent e3ee9b1 commit bc2b4d8
File tree
1 file changed
+26
-0
lines changed- Section 25 Collections Frameworks/List Interface/ArrayList/src
1 file changed
+26
-0
lines changedLines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments