Tags » Java 2

RestTemplate and Proxy Authentication explained

Some time ago I’ve faced with requirements regarding retrieving data using REST behind proxy. There were some code samples available but I was really worried about thread safety and leaking resources. 659 more words

Java

Oracle Certified Associate Java 8 : Date and Time

Java 8 brings a new package java.time for dealing with date and time. New classes are much better than the old one, easy to use, more human friendly. 35 more words

Java

Java Counting Duplicate Elements in Array

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class CountDuplicatedList {

  public static void main(String[] args) {

	List<String> list = new ArrayList<String>();
	list.add("a");
	list.add("b");
	list.add("c");
	list.add("d");
	list.add("b");
	list.add("c");
	list.add("a");
	list.add("a");
	list.add("a");

	System.out.println("\nExample 1 - Count 'a' with frequency");
	System.out.println("a : " + Collections.frequency(list, "a"));

	System.out.println("\nExample 2 - Count all with frequency");
	Set<String> uniqueSet = new HashSet<String>(list);
	for (String temp : uniqueSet) {
		System.out.println(temp + ": " + Collections.frequency(list, temp));
	}

	System.out.println("\nExample 3 - Count all with Map");
	Map<String, Integer> map = new HashMap<String, Integer>();

	for (String temp : list) {
		Integer count = map.get(temp);
		map.put(temp, (count == null) ? 52 more words
Java

String in Java

What is String? String is nothing but a group of characters. In Java, we have String and String literals terms defined on how we create String. 16 more words

Java

Understanding Stack Trace in Java

Those who have worked in Java have heard about stack trace. To understand how it works, blog post was posted on discovertechno blog Understanding Stack Trace in Java.

Java

How to run database integration tests 20 times faster

Follow @vlad_mihalcea

Introduction

In-memory databases such as H2, HSQLDB, and Derby are great to speed up integration tests. Although most database queries can be run against these in-memory databases, many enterprise systems make use of complex native queries which can only be tested against an actual production-like relational database. 937 more words

Java