AmitDiwan has Published 10744 Articles

Iterator vs Collection in Java

AmitDiwan

AmitDiwan

Updated on 04-Jul-2020 08:53:41

437 Views

IteratorIt is used in Collection Framework so as to retrieve elements as and when they are required.public interface IteratorIt can be used with the ‘next’ function to move and access the next elements. The ‘remove’ function can be used to remove an element from the data structure.It is quicker in ... Read More

Island of Isolation in Java

AmitDiwan

AmitDiwan

Updated on 04-Jul-2020 08:51:19

1K+ Views

After an object has been used, it is deallocated from the memory using the Garbage Collector class. The objects are destroyed based on the fact that no reference to that object is present. The Garbage Collector class calls the ‘finalize’ function on the object that needs to be destroyed.What is ... Read More

Is an array a primitive type or an object in Java?

AmitDiwan

AmitDiwan

Updated on 04-Jul-2020 08:45:15

2K+ Views

Array is considered to be an object in Java. The reason behind this is that an array can be created using the ‘new’ keyword. The ‘new’ keyword/operator is always used to create an object. This is how an array is perceived as an object.The direct parent class or super class ... Read More

Interning of String in Java

AmitDiwan

AmitDiwan

Updated on 04-Jul-2020 08:42:01

309 Views

String interning is a process wherein a single copy of every distinct string value is stored. In addition to this, the strings can’t be changed too. This way, strings can contain the same data as well as share the same memory. This way, the memory required would be greatly reduced.When ... Read More

Internal working of Set/HashSet in Java

AmitDiwan

AmitDiwan

Updated on 04-Jul-2020 08:40:41

6K+ Views

Set data structure is used to store unique values only, meaning no duplicate values would be stored in a set. When a HashSet is created, it internally implements a HashMap. An element can be inserted into the HashSet using the ‘add’ function. This internally calls the ‘put’ function since a ... Read More

Internal Working of HashMap in Java

AmitDiwan

AmitDiwan

Updated on 04-Jul-2020 08:36:59

2K+ Views

The function ‘hashCode’ is used to get the hash code of an object in Java. This is an object of super class Object. It returns the object reference’s memory as an integer. It is a native function, which means no direct method in Java can be used to fetch the ... Read More

Interesting facts about null in Java

AmitDiwan

AmitDiwan

Updated on 04-Jul-2020 08:34:37

185 Views

There are many facts associated with null in Java. We will discuss a few of them here with examples −The default value of any reference variable in Java is always null.Example Live Demopublic class Demo{    private static Object my_obj;    public static void main(String args[]){       System.out.println("The default ... Read More

Interesting Facts about Java

AmitDiwan

AmitDiwan

Updated on 04-Jul-2020 08:31:16

437 Views

Java was built by sheer accident, a team of developers were busy building a set top box, and began cleaning C++. When they were winding up these changes, they ended up discovering Java and its runtime environment.Many of you might be aware of this, but for those who aren’t, Java ... Read More

Interesting facts about Increment and Decrement operators in Java

AmitDiwan

AmitDiwan

Updated on 04-Jul-2020 08:19:58

194 Views

There are many interesting facts with respect to increment and decrement operators in Java. We will discuss a few of them with examples −The increment and decrement operators can’t be used with the ‘final’ variables. This is due to the fact that variables associated with ‘final’ keyword can’t be changed ... Read More

Interesting facts about Array assignment in Java

AmitDiwan

AmitDiwan

Updated on 04-Jul-2020 08:18:01

186 Views

There are many facts with respect to array assignment, and we will discuss a few of them with working examples here −While creating array object type, the element that would be present inside the array can be declared as type objects or as child class’s object.Example Live Demopublic class Demo{   ... Read More

Advertisements