Burak Aktas Software Engineer

Convert objects to/from JSON by Jackson example

We will see a simple example about converting objects to/from JSON objects in Java by Jackson. First, add maven dependency for jackson.

<dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.4.4</version>
</dependency>

Arquillian Example for CDI Dependency Injection

Arquillian is a platform which provides integration tests by deploying, running containers so that we can easily use cdi beans in tests. In this tutorial we will see how to inject and use cdi beans in test classes by running Arquillian.

As a first step we have to add Arquillian core library in our pom.xml in the dependencyManagement block. Well it is completely optional, and you can add it in dependencies section.

Java CDI Dependency Injection Example

CDI (Context and Dependency Injection) is a specification defined in [JSR-299][1]. Major aim is loose coupling by [dependency injection][2].In this tutorial we will see how to use CDI Dependency Injection in java with three different ways;

  • Field injection
  • Constructor injection
  • Setter method injection

Graphs

Graphs are data structures to represent road networks, the web, social networks etc. Moreover, hundreds of computational problems are related to graphs.They have two main ingredient which are;

  • \(Vertices (V)\) as known as nodes.
  • \(Edges (E)\) : pair of vertices
    • can be undirected.
    • or directed.

Quicksort

Quicksort is a sorting algorithm which applies divide and conquer paradigm. Quicksort has a worst case running time of \( O(n^{2}) \) , however, it has running time of \( O(n​ logn) \) on average which makes quicksort very efficient. Moreover, it works in-place but not stable. The performance of quicksort depends on selecting the pivot, and starting to partition around it. During the partition procedure subarrays divided into four regions; \( \leq x \), \( > x \), \( unrestricted \) ,and finally the \( pivot \).