What is the Python Yield Statement?

Learn about the Python yield statement which is used to create generators.

“Count your age by friends, not years. Count your life by smiles, not tears.”
― John Lennon

1. Introduction

Python provides an yield statement which allows you to create generator functions. What is a generator function and how does the yield statement help with it? Let us find out in this article.

Continue reading “What is the Python Yield Statement?”

What are JavaScript Closures?

Learn about JavaScript Closures.

“Everything must be made as simple as possible. But not simpler.”
― Albert Einstein

1. Introduction

JavaScript supports closures which is a concept that is somewhat hard to understand, so let us step you through some examples to help.

Continue reading “What are JavaScript Closures?”

Java – Zip Folder Tutorial

Learn how to zip a folder in Java

“Quotation, n: The act of repeating erroneously the words of another.”
― Ambrose Bierce, The Unabridged Devil’s Dictionary

1. Introduction

Java provides good support for reading and writing zip files. In this article, let us learn how to create a zip file from the contents of a folder in java.

Continue reading “Java – Zip Folder Tutorial”

Java Calendar Examples

A Tutorial covering the basics of Java Calendar and Date Manipulation

“Let us tenderly and kindly cherish therefore, the means of knowledge. Let us dare to read, think, speak, and write .”
― John Adams

1. Introduction

Java provides a Calendar class for performing data manipulation. A closely related class is the Date class, used to represent a specific instant in time starting from epoch (January 1, 1970 00:00:00.000 GMT). Let use learn how we can use these two classes for date and time manipulation.

Continue reading “Java Calendar Examples”

Java Number Conversion

Learn the intricacies of Java Number to String Conversion and vice-versa.

“It is a good thing for an uneducated man to read books of quotations.”
― Winston S. Churchill

1. Introduction

Number conversion is a frequent need while programming. You may have a need to convert from a hex string, decimal string or octal string. Or maybe you are using a number from a different base. The reverse conversion is also required many times: converting from a decimal integer to hex string, octal string, etc. Let us see how we can do these conversions.

Continue reading “Java Number Conversion”

Java Path API Tutorial

Learn the intricacies of using the Java Path API in this tutorial

“The mind is not a vessel to be filled, but a fire to be kindled.”
― Plutarch

1. Introduction

The Java Path API is a new introduction starting from version 1.7. It provides convenience methods for manipulating file paths in a system-independent way. Let us examine the usage of the Path API in more detail.

Continue reading “Java Path API Tutorial”

Java – Reading a Large File Efficiently

Efficiently read text and binary files in Java

“The world is a book and those who do not travel read only one page.”
― Augustine of Hippo

1. Introduction

What’s the most efficient and easiest way to read a large file in java? Well, one way is to read the whole file at once into memory. Let us examine some issues that arise when doing so.

Continue reading “Java – Reading a Large File Efficiently”

Java ThreadLocal – Proper Usage

Learn how to properly create and use ThreadLocal to share data between threads.

“A lie gets halfway around the world before the truth has a chance to get its pants on.”
― Winston S. Churchill

1. Introduction

Getting multi-threaded programming right is something of an art; it can be hard to foresee and avoid the many pitfalls. One such hazard comes from attempting to share a variable across multiple threads.

Continue reading “Java ThreadLocal – Proper Usage”

Convert Java 8 Streams to Collections

Process data using Java 8 Streams and store in Collections including List, Set or Map.

“If we knew what it was we were doing, it would not be called research, would it?”
― Albert Einstein

1. Introduction

Java 8 Streams provide a cool facility to combine several operations in a single statement and express it concisely. Once the data is processed, you can collect the data in a List (or another collection). In this article, we present several methods to collect the results of these stream operations into collections.

Continue reading “Convert Java 8 Streams to Collections”

Using a Java TreeSet

Covers the basic operations on a java TreeSet including creation, iteration, finding elements, etc.

The unexamined life is not worth living.
― Socrates

1. Introduction

A java Set is a Collection containing only unique elements. A TreeSet is an implementation of the Set which uses a Red-Black tree implementation. In this article, we demonstrate how to properly create and use a TreeSet.

Continue reading “Using a Java TreeSet”