Array Reflection
Java’s reflection API allows developers to inspect and manipulate arrays at runtime.
Java
/*package whatever //do not write package name here */ import java.io.*; class GFG { public static void main(String[] args) { Class<?> arrayClass = Class.forName( "[I" ); // [I represents an int array } } |
25 Interesting Facts about Arrays in Java
Java arrays are the workhorses of many programs, offering a structured way to store and manipulate data. While arrays are a fundamental concept, there are intriguing facts that developers may not be aware of for Java Arrays. In this blog post, we’ll explore 25 interesting facts about arrays in Java, shedding light on their nuances and capabilities.
Table of Content
- 1. Zero-Based Indexing:
- 2. Fixed Size:
- 3. Primitive and Object Types:
- 4. Reference Variables:
- 5. Dynamic Initialization:
- 6. Array Copying:
- 7. Varargs and Arrays:
- 8. Arrays.asList():
- 9. Array Equality:
- 10. The Enhanced for Loop:
- 11. Cloneable Interface:
- 12. Arrays.deepToString():
- 13. Arrays.sort():
- 14. Parallel Array Sorting:
- 15. Jagged Arrays:
- 16. Memory Efficiency:
- 17. Array Initialization Shortcut:
- 18. Array Length Attribute:
- 19. ArrayDeque vs. Arrays:
- 20. Arrays.fill():
- 21. Garbage Collection:
- 22. Array Reflection:
- 23. Arrays and Generics:
- 24. Array Performance:
- 25. Arrays in Streams: