Java Locale Class Example

java-thumbnail

A locale is a set of parameters which represents specific locale such as geographic region or political region that shares the same language and customs. A locale object may includes user’s language, country, and any special variant preferences that user needs. A Locale class which requires operation to perform its task is called as locale-sensitive […]

Java HashSet Example

java-thumbnail

HashSet is a collection of unique elements (objects). The HashSet is available with collection package and extends AbstractSet and implements the set interface. The below diagram shows the HashSet class hierarchy where HashSet is extended from the AbstractSet where AbstractSet implements the set interface and AbstractCollection which is extend from collection framework where collection framework […]

Java HashTable Example

java-thumbnail

Collection framework is collections of interfaces, implementations and algorithms, which are used to store, retrieve and manipulate the data. In the version of Java 1.0, HashTable was introduced where it did not use map. This version was upgraded in java 1.2, to implement Map interface making it as part of the Java Collections framework. HashTable […]

Java HashMap Example

java-thumbnail

HashMap is collection which stores in the form of key-value pairs, where key is reference and value is actual data. HashMap always works on the principle of hashing to transform key-value pairs into the map. It uses hash table to store the map. It contains unique elements. We cannot use duplicate data for the keys […]

Java LinkedList Example

java-thumbnail

LinkedList contains group of elements in the form of nodes. The linked lists are used to store array of data. It is a linear data structure in which each element is separate object. LinkedList contains set of nodes. Each node contains some of the data and link to the next node. When link of next […]

Create Custom Formatter for Logger Handler

java-thumbnail

This example shows how to write a simple custom Formatter for the logging in Java. Java provides java.util.Formatter class for extending the format of the messages and that can be applied to the handlers. In our previous example, I have explained how to write the logging handlers. If you want to write the custom formatters, […]

java.util.Formatter Example

java-thumbnail

java.util.Formatter class is used for formatting the values passed to the format() method. This class become part of Java since the Java 5 release. This feature is taken from the C language to format the string, numbers, date, etc. in the simplified manner. There is set of variables and expression defined for formatting the values. […]

Java Logging Handlers Example

java-thumbnail

In our previous example I have explained how to write a simple logging configuration in your Java program. This example shows how to use the different log handlers for printing the log messages. Log handlers are the medium where the log messages has to be transfered for the future reference. In bigger applications, the handlers […]

Java Logging Example (java.util.logging.Logger)

java-thumbnail

In our application, logging is one of the important mechanism to capture the messages thrown by the applications. One of the most popular logging framework is log4j which provides the logging in your applications. However, you can implement the logging without adding any third party implementations by the JDK’s built in logging APIs. java.util.logging package […]

Java Timer Example

java-thumbnail

In Java, we have java.util.Timer class for scheduling the tasks at the frequent intervals. The steps for creating the simple job using the java.util.Timer class is: Create the task / job by extending the java.util.TimerTask. A task has to extend java.util.TimerTask and implement the run() method Create the Timer instance to manage the tasks. You […]