Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

 

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

 

and many more ....

 

Receive Java & Developer job alerts in your Area

I have read and agree to the terms & conditions

 

Convert HashSet to Object array example

Bipartite Graph

With this example we are going to demonstrate how to convert a HashSet to an Object array. In short, to convert a HashSet to an Object array you should: Create a new HashSet. Populate the hashSet with elements, using add(E e) API method of HashSet. Invoke toArray() API method. This method returns an array containing all of the elements in ...

Read More »

Check for element existence in HashSet example

Bipartite Graph

This is an example of how to check for an element existence in a HashSet. Checking if an element exists in a HashSet implies that you should: Create a new HashSet. Populate the hashSet with elements, using add(E e) API method of HashSet. Invoke contains(Object value) API method of HashSet, with a specified element as parameter. The method returns true ...

Read More »

Sort Vector using Comparator example

Bipartite Graph

In this example we shall show you how to sort a Vector using a Comparator. The Collections API provides methods to get a Comparator and use it to sort a Vector. To sort a Vector using a Comparator one should perform the following steps: Create a new Vector. Populate the vector with elements, using add(Object o) API method of Vector. ...

Read More »

Sort ArrayList using Comparator example

Bipartite Graph

With this example we are going to demonstrate how to sort an ArrayList using a Comparator. We are using Collections API, that provides methods to get and use a Comparator. In short, to sort an ArrayList using a Comparator you should: Create a new ArrayList. Populate the arrayList with elements, using add(E e) API method of ArrayList. Invoke reverseOrder() API ...

Read More »

StringTokenizer with specified delimiter

Bipartite Graph

This is an example of how to use a StringTokenizer with a specified delimiter in order to break a String into tokens. We can use the StringTokenizer with a delimiter to break a String, using two methods: In the first method, we use the StringTokenizer(String str, String delim) constructor of StringTokenizer get a string tokenizer for the specified string and ...

Read More »

Tokenize String with StringTokenizer

Bipartite Graph

In this example we shall show you how to tokenize a String with StringTokenizer. The StringTokenizer is used to break a String into tokens. To tokenize a String with StringTokenizer one should perform the following steps: Get a new StringTokenizer for a specified String, using the StringTokenizer(String str) constructor. Get the tokens of the String, using hasMoreTokens() and nextToken() API ...

Read More »

Reverse String with StringTokenizer

Bipartite Graph

With this example we are going to demonstrate how to reverse a String with a StringTokenizer. The StringTokenizer is used to break a String into tokens. In short, to reverse a String with a StringTokenizer you should: Get a new StringTokenizer for a specified String, using the StringTokenizer(String str) constructor. Create a new empty String, that will be the reversed ...

Read More »

StringTokenizer Count Tokens

Bipartite Graph

This is an example of how to use a StringTokenizer to count the tokens of a String. The StringTokenizer is used to break a String into tokens. Using a StringTokenizer to count the tokens of a String implies that you should: Get a new StringTokenizer for a specified String, using the StringTokenizer(String str) constructor. Invoke countTokens() API method of StringTokenizer. ...

Read More »

Sort ArrayList example using Collections sort

Bipartite Graph

In this example we shall show you how to sort an ArrayList using sort operation of the Collections API. To sort an ArrayList using Collections sort one should perform the following steps: Create a new ArrayList. Populate the arrayList with elements, using add(E e) API method of ArrayList. Invoke sort(List list) API method of Collections to sort the arrayList elements ...

Read More »

Search elements in ArrayList example

Bipartite Graph

With this example we are going to demonstrate how to search elements in a ArrayList. In short, to search elements in a ArrayList you should: Create a new ArrayList. Populate the arrayList with elements, using add(E e) API method of ArrayList. Check if an element exists in the arrayList, withcontains(Object element) API method of ArrayList. The method returns true if ...

Read More »