Core Java Category

Thread-safe Hash Map in Java and their performance benchmark

1. Java Thread-safe Map Overview The Map object is an associative containers that store elements, formed by a combination of a uniquely identify key and a mapped value. In Java, the most important Map implementation is HashMap, unfortunately it is not synchronized. Tips: A map cannot contain duplicate keys, each key can map to at most one value. […]

How to get the stack trace of current thread in Java

This tutorial demonstrates how to dump stack track of the current thread in Java, this is very useful troubleshoot or debug skill to identify the states of current running thread. Use Thread.currentThread().getStackTrace() to retrieve an array of StackTraceElements that represent the current stack trace .

Java Map Iterator Example

Java Map Overview Map is an important Java collection implementation defined in java.util package, it is designed to store with key and value  element pairs. In this how-to example, let’s go over how to iterate over a map in Java. Way 1: Iterate over a Map using Java Map Iterator. Maps do not provide an […]

Java Book Recommendations: Top and Best Java Books

Top1 Java Book Recommendation: Thinking in Java Author: Bruce Eckel, Date of publication: February 2006, Reviewer: Meera Subbarao. Download: Description: Thinking in Java is a comprehensive guide to the Java programming language, it gives insight of java and covers all aspects of core technologies including OO, Thread, Concurrency, IO, GUI/Swing and so on. It […]

Java Remote Debugging on WebLogic Server with Eclipse

Oracle’s WebLogic is a leading Java-based server software application that runs on a middle tier. Eclipse is an open-source community that develops open platforms and products. As they are both industry standard leading product, developers usually integrate the two toolkits together to develop the J2ee application, in order to significantly fix a server-side Java problem appeared trivia, we need […]

How to HotSwap Java Code into JVM (Redefinition Example)

Java HotSwap Overview The terms of development is actually writing code, testing and fixing bugs with frequency, the most of common thing we want is that the modified java classes to be effective immediately without restarting the application. In this tutorial, we guide how Java classes can be reloaded without dynamic class loaders, and shows example […]

How to Sort a List in Java

We usually have problem to sort the specified list into ascending order, according to the natural ordering of its elements. This article look though how to sort list/arrarylist in java. Assuming you have created a list, added the instantiation of string as the elements of the lists, please note all elements in the list must […]

Java Access Modifiers: Public, Protected, Friendly and Private

The access to classes, constructors, methods and fields are regulated using access modifiers in Java, by signing the access Modifiers, a class or method can control what information or data would be exposed to other classes, the developer can take full advantage of java access modifiers to maximize re-usability and refectory.

Here is one way to perform a system-wide (global) keyboard shortcut in out-of-JVM applications. package com.asjava; import java.awt.*; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.StringSelection; import java.awt.event.KeyEvent; public class Main { public static void main(String[] args) throws Exception { Thread.sleep(5000L); java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable tText = new StringSelection(“Where this come from?”); clipboard.setContents(tText, null); Robot robot = new […]

How Do I Make an Executable JAR File

What’s is Jar? it is built on the ZIP file format and have the .jar file extension and introduced to Java to describe Java binary files, it is combination of all classes and corresponding Metadata information. A magic feature of Java2 is the ability to make a Jar file executable, It is amusing as running it […]