One of the most significant advantages of Java is its memory management. You simply create objects and Java Garbage Collector takes care of allocating and freeing memory. However, the situation is not as simple as that, because memory leaks frequently occur in Java applications.
Memory
Java Reflection Tutorial
What is reflection? “Reflection is commonly used by programs which require the ability to examine or modify the runtime behavior of applications running in the Java virtual machine.” This concept is often mixed with introspection. The following are their definitions from Wiki: Introspection is the ability of a program to examine the type or properties … Read more
What does a Java array look like in memory?
In Java, an array stores either primitive values (int, char, …) or references (a.k.a pointers) to objects.
When an object is created by using “new”, a memory space is allocated in the heap and a reference is returned. This is also true for arrays, since arrays are objects in Java.
How does Java handle aliasing?
What is Java aliasing? Aliasing means there are multiple aliases to a location that can be updated, and these aliases have different types. In the following example, a and b are two variable names that have two different types A and B. B extends A. B[] b = new B[10]; A[] a = b; … Read more
Java Force Garbage Collection – Code Example
Garbage collection in java can not be enforced. But still sometimes, we call the System.gc( ) method explicitly. System.gc() method provides just a “hint” to the JVM that garbage collection should run. It is not guaranteed!