Populating the entire array with different elements

In this post under Java Collections, I will show with example an api provided in “Arrays” class that will populate an array with different element. We are talking about “Arrays” class static method “setAll”. It takes two arguments1) the array to be populated2) a function that will generate the elements that are to be inserted…… Continue reading Populating the entire array with different elements

Populating the entire array with same element

In this post under Java Collections, I will show with example an api provided in “Arrays” class that will populate any array with a particular element. We are talking about “Arrays” class static method “fill”. It takes two arguments1) the array to be populated2) the element to be fill int array For our example I…… Continue reading Populating the entire array with same element

Arrays toString method

In this post under Java Collections, I will show with example how to convert an array into its string representation. In Java, any object when converted to its string representation, it calls the object’s “toString” method. The default behavior of “toString” method is to print the below information getClass().getName() + ‘@’ + Integer.toHexString(hashCode()) In case…… Continue reading Arrays toString method

Retrieving selected attribute when doing basic search

In this post under Java LDAP, I will show with example how to retrieve specific attributes when doing basic search. For our example we will use the below ldap hierarchy. Now lets see the main code which actually does the search. Main class 1 package package11; 2 3 import javax.naming.Context; 4 import javax.naming.NamingEnumeration; 5 import…… Continue reading Retrieving selected attribute when doing basic search

Arrays copyOfRange method example

In this post under Java collections, I will show with example the purpose of “Arrays” class “copyOfRange” method. In the previous post under Java collections, I showed with example the purpose of “Arrays” class “copyOf” method. This method copies all the elements of input array to destination array. But what if we want to copy…… Continue reading Arrays copyOfRange method example