Tagged: Java

Insertion Sort: Implementation and Analysis

Insertion Sort Overview Insertion sort is simple, but poorly performing sort algorithm that can sort a list in place. The Insertion sort algorithm works by splitting the input list into two partitions; a sorted part and an unsorted part. At the start of Insertion sort, the sorted part consists of 1 item; the first item in the input. Insertion sort then takes the first item of the unsorted part and...

Bubble Sort: Implementation and Analysis

Bubble Sort Overview Bubble Sort is a simple sort algorithm. When sorting a given list of items, in general, Bubble sort will make multiple passes over the list of items. During each pass, Bubble sort compares each adjacent pair of items. If the pair is in the correct order, Bubble sort does nothing and moves to the next adjacent pair. If the pair is out of order, Bubble sort swaps...

TestNG Basics

Unit tests are written to ensure that small units of code function as intended. When it comes to Unit tests, the higher your code coverage, the higher your confidence when refactoring and/or extending code functions and features. Unit tests play an incredibly important role when it comes to sustaining and maintaining code. TestNG is a simple, yet powerful unit test framework for Java. TestNG enables you to construct test cases...

Java Impersonation using JNA and Waffle

Have you ever had the need to create a Java application that executes on behalf of a logged in Windows user? You can! In this post we will use JNA and Waffle to: Create a simple Java application to impersonate a Windows domain user. In a future post, we will see how this can also be done in a servlet! 1. Create a Java application to impersonate a Windows domain...

Java Getters and Setters with Lombok

Sick of all the boilerplate code required to create simple getter/setters with Java? Checkout project Lombok! Let’s suppose we want to create a simple class with the following: public getter/setter for age protected setter for name With Vanilla Java, we might do the following: However, with Lombok (we remove most of the cruft) and we simply write: How cool?!?! Thank you!