Archive for category Core Java

Bubble Sort in Java

Bubble Sort is a generic algorithm to sort the elements and can be implemented in any programming language. The algorithm gets its name from the way smaller elements “bubble” to the top of the list. it is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair […]

, , ,

Leave a comment

List of all Locales

SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. It allows for formatting (date -> text), parsing (text -> date), and normalization. SimpleDateFormat.getAvailableLocales() method returns an array of Locale objects for which localized DateFormat instances can be obtained. Code snippet below lists all available locales Output References

, ,

Leave a comment

What is the difference between ArrayList and LinkedList

LinkedList and ArrayList are two different implementations of the List interface. LinkedList implements it with a doubly-linked list. ArrayList implements it with a dynamically resizing array. The difference between the two boils down to the basic difference between and Array and LinkedList. Here are the differences between them: Since Array is an index based data-structure […]

, , , , ,

1 Comment

Using properties file in java application

Properties files are a cool place to store your configuration details like database connection properties, error messages and other configurations for your program. You can use properties file in your application using following utility class. This class basically loads your properties file on first attempt to access any property on further attempts to access any […]

, , , , ,


How to Write formatted xml in Java

To write a formatted xml in java you have to set some properties of Transformer Above settings instruct Transformer to spit a formatted xml. See complete example below Output:

, , , ,

1 Comment

UncaughtExceptionHandler in Java

If you do not handle a runtime exception in your program, the default behaviour will be to terminate the program and dump the call stacktrace on the console. Java provides an elegant mechanism of handling Runtime Exceptions that you might have not handled in your program. UncaughtExceptionHandler can be defined at three levels. From highest […]

, , , , , , , ,

Leave a comment