In the next 15 min you learn how to synchronize access to mutable shared variables via the synchronized keyword, locks and semaphores. The majority of concepts shown in this article also work in older versions of Java. However the code samples focus on Java 8 and make heavy use of lambda expressions and new concurrency … Continue reading Java Concurrency Tutorial: Synchronization and Locks
Java
Java Concurrency Tutorial: Threads and Executors
This guide teaches you concurrent programming in Java 8 with easily understood code examples. It's the first part out of a series of tutorials covering the Java Concurrency API. In the next 15 min you learn how to execute code in parallel via threads, tasks and executor services. The Concurrency API was first introduced with … Continue reading Java Concurrency Tutorial: Threads and Executors
HashSet in Java
Class HashSet<E> java.lang.Object java.util.AbstractCollection<E> java.util.AbstractSet<E> java.util.HashSet<E> Type Parameters: E - the type of elements maintained by this set All Implemented Interfaces: Serializable, Cloneable, Iterable<E>, Collection<E>, Set<E> Direct Known Subclasses: JobStateReasons, LinkedHashSet public class HashSet<E> extends AbstractSet<E> implements Set<E>, Cloneable, Serializable This class implements the Set interface, backed by a hash table (actually a HashMap instance). … Continue reading HashSet in Java
HashMap in Java
Class HashMap<K,V> java.lang.Object java.util.AbstractMap<K,V> java.util.HashMap<K,V> Type Parameters: K - the type of keys maintained by this map V - the type of mapped values All Implemented Interfaces: Serializable, Cloneable, Map<K,V> Direct Known Subclasses: LinkedHashMap, PrinterStateReasons public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable, Serializable Hash table based implementation of the Map interface. This implementation provides … Continue reading HashMap in Java
Comparator Interface and sorting in Java
Comparator interface is used to order the objects of user-defined classes. A comparator object is capable of comparing two objects of two different classes. Following function compare obj1 with obj2 Syntax: public int compare(Object obj1, Object obj2): Suppose we have an array/arraylist of our own class type, containing fields like rollno, name, address, DOB etc … Continue reading Comparator Interface and sorting in Java
Where is Java used in Real World?
If you are a beginner and just started learning Java, you might be thinking where exactly Java is used? You don't see many games written in Java except Minecraft, desktop tools like Adobe Acrobat, Microsoft Office are not written in Java, neither is your operating systems like Linux or Windows, so where exactly people use … Continue reading Where is Java used in Real World?
How to configure Processing to run on Raspberry Pi?
Processing is an open source programming language (processing.org) and environment for people who want to create images, animations, and interactions. This is how to install it on your Raspberry PI: install the java 6 sdk sudo apt-get install librxtx-java openjdk-6-jdk download and unzip the Linux (x86) version of Processing 1.5.1 to the /home/pi directory http://processing.googlecode.com/files/processing-1.5.1-linux.tgz … Continue reading How to configure Processing to run on Raspberry Pi?
How to run system commands Java (Linux environment)
In Python, we use import os os.system('sudo vncserver stop') What about in Java. Below is one example. import java.io.*; public class java_system_call { public static void main(String args[]) { String s = null; try { // run the Unix "ps -ef" command // using the Runtime exec method: Process … Continue reading How to run system commands Java (Linux environment)
Write once, run anywhere (Java)
This is an interesting reading from Wikipedia. "Write once, run anywhere" (WORA), or sometimes write once, run everywhere (WORE), is a slogan created by Sun Microsystems to illustrate the cross-platform benefits of the Java language. Ideally, this means Java can be developed on any device, compiled into a standard bytecode and be expected to run … Continue reading Write once, run anywhere (Java)
A comparison between Java and Python
This is a post that interests me. (Is WebFaction a good hosting service provider?) Comparing Python and Java A programmer can be significantly more productive in Python than in Java. How much more productive? The most widely accepted estimate is 5-10 times. On the basis of my own personal experience with the two languages, I … Continue reading A comparison between Java and Python