Write a program to count the occurrences of an element in an array is one of the basic question which will be asked in an Java Interview. After the introduction of Collection framework performing this operation is a pretty easy task. Let see how we can count the occurrence using HashMap. [Read more…]
In this tutorial we will learn how to copy all the elements of the ArrayList to an Array. We will be using toArray() method of java.util.ArrayList class.
This is one of the popular question in the java world. I have encountered this situation a lot of times in my life which made me to write up this article on converting a Java Array to ArrayList. Almost everybody knows that the Arrays are used to store primitive datatypes and ArrayList is used to store the Objects. Lets see the different ways to convert.