1. QuickSort Java Example

    Quicksort algorithm is one of the most used sorting algorithm, especially to sort large lists/arrays. Quicksort is a divide and conquer algorithm, which means original array is divided into two arrays, each of them is sorted individually and then sorted output is merged to produce the sorted array. On the average, it has O(n log […]

  2. Bubble Sort Java Example

    Bubble Sort is a simple and slow sorting algorithm that repeatedly steps through the collection, compares each pair of adjacent elements and swaps them if they are in the wrong order. In the sorting algorithm, if you watch the move of the elements with higher orders (i.e. larger values), they are like bubbles in the […]

  3. Selection Sort Java Example

    Selection Sort is a simple and slow sorting algorithm that repeatedly selects the lowest or highest element from the un-sorted section and moves it to the end of the sorted section. Mostly, performance wise, it is slower than even Insertion Sort. It does not adapt to the data in any way so its runtime is […]

  4. Insertion Sort Java Example

    Insertion Sort is a simple and slow sorting algorithm that repeatedly takes the next element from the un-sorted section and inserts it into the sorted section at the correct position. The idea of insertion sort comes from our daily life experiences. For example, when you play cards with your friends, you will insert the next […]

  5. Java System Properties

    Java maintains a set of system properties for its operations. Each java system property is a key-value (String-String) pair such as “java.version”=”1.7.0_09“. You can retrieve all the system properties via System.getProperties() or you can also retrieve individual property via System.getProperty(key). Please note that Access to system properties can be restricted by the Java security manager […]

  6. Tomcat – Enable/disable directory listing

    When your application is deployed in tomcat webserver and you request a URL which refers to a directory instead of a file, e.g., http://host:port/helloWorldApp/, you can configure Tomcat to serve the directory listing, or a welcome file, or issue error “404 Page Not Found”. Let’s see how you can enable or disable directory listing in […]

  7. Java Date Examples

    In this tutorial, I am listing down ready to use examples of java date class. These Date class usecase are frequently required, and having them in one place will help in saving time for many of us. Java Date Class Examples Convert Date to String Refer SimpleDateFormat JavaDoc for detail date and time patterns. Below […]

  8. Java get current date/time examples

    Java offers a lot of useful ways to get current date or get current time using Date, Calendar and newly introduces Java 8 Date/Time API classes. Let’s see some examples to understand them in detail. Table of Contents Get current date/time using Date class Get current date/time using Calendar class Get current date/time using LocalDateTime […]

  9. Merge Sort Java Example

    In computer science, merge sort (also commonly spelled mergesort) is an O(n log n) comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output. Mergesort is a divide and conquer algorithm. Divide and conquer algorithms divide the original data into […]

  10. Java Multi-threading Evolution and Topics

    One of our reader, Anant, asked this extremely good question to elaborate / list down all related topics that we should know about multi-threading including changes made in java 8.( Beginner level to Advance level). All he wanted to know was evolution of Multi-threading Framework in Java from Simple Runnable interface to latest feature in […]

Java blog for smart concepts and coding practices