This post highlights a simple example to demonstrates how to convert a char datatype to a string object. Lets look at the example program. Output
Java
How To Convert String To Char Array In Java?
This tutorial is simple example for converting a string object into a simple character array. Lets look at the example. Output…
How To Convert Char Array To String In Java?
This tutorial is simple example for converting a character array into a simple string object. In general, there are two ways to convert the character array to string object, First approach is to pass the array into the string constructor and second approach is to using the String.valueOf(). Lets look at the example. Output…
StringTokenizer Example
StringTokenizer in java.util package is very useful for spliting the length string into the pieces. You can pass a delimeter to the StringTokenizer constructor to split the string where ever that delimeter appeared in the string. If you have not passed any delimeter, by default it splits the string using the empty space in the …
Compressing and Uncompressing File Example in Java
Compressing and Uncompressing of the files is one of the common utility we use in our daily life. If you are using windows, using WinZip is very common to compress the files and sent to others. The advantage of compressing the files is to save the memory occupied for the file in the disk. It …
TreeSet in Java
TreeSet class implements the Set interface and stores the data in tree structure. The values are stored in sorted and ascending oreder. It is quite fast in retrieval of elements. This makes TreeSet is most prefered choice for storing the large amount of data in sorted order and want to retrieve it fast. This supports …
How To Sort Java Object Using Comparable And Comparator?
This tutorial shows how to use java.util.Comparator and java.lang.Comparable to sort a Java object based on its property value. Here I have created Employee object with Name and Age properties, we will be able to sort the list of objects based on the values in the property’ Lets look at the example. Employee.java ComparatorExample.java Output …
HashTable in Java
HashTable class was originally added as part of java.utill package and extended the Dictionary class. From Java 2, it is re-engineered to implement the Map interface and made as part of the collections framework. HashTable is similar to HashMap except that HashTable is synchronized. It is very much similar to HashMap, stores the key-value pairs. …