Java

Java Reflection Tutorial

Java reflection is an advanced feature and is the ability to examine or modify the run-time behavior of applications.  Java reflection is primarily used in applications like test tools, debuggers, class browsers etc. Reflection provides the ability to examine private members of a class and also has associated performance overhead since the types are dynamically …

Java Reflection Tutorial Read More »

Java Properties Example

Handling persistent properties is an important aspect in software design to prevent hard coding values in code. Properties allow the customization of values like username, password, port numbers etc. during run time and provides flexibility to the implementation. Java support simple APIs to handle read and store properties. This article provides an introduction to working …

Java Properties Example Read More »

Java UDP Sockets

TCP/IP sockets explained in this article is a reliable form of communication. However there is additional overhead involved in terms of error handling, congestion control etc. in TCP/IP communication. The other alternative available is to use UDP (User Datagram Protocol). UDP protocol doesn’t guarantee that the message sent is transmitted reliably. Since UDP involves less overhead …

Java UDP Sockets Read More »

Java TCP/IP Sockets

TCP/IP (Transmission Control Protocol/ Internet Protocol) is the protocol of the internet used to interconnect hosts. TCP/IP  provides reliable communication between 2 end points. This article provides an introduction to work with TCP/IP Sockets using Java. A Socket is an end point of communication flow and is a combination of IP address and a port …

Java TCP/IP Sockets Read More »

Java URL and URLConnection

Java Networking APIs provide a set of classes to interact with the internet. The primary classes include URL, URLConnection and HttpURLConnection. This tutorial provides examples to construct URLs and to access internet resources.  Read properties of URL URL represents the Uniform Resource Locator a resource on the world wide web.  URL url1 = new URL(“http”, …

Java URL and URLConnection Read More »

Java Annotations

Annotations is a form of meta-data to the Java code and doesn’t directly impact the behavior of the code. This article covers key concepts around annotations in Java with examples. Basic format of Annotation The at sign @ indicates start of annotation. In the example below we use an annotation @SuppressWarnings with value of “deprecation”. …

Java Annotations Read More »

JDBC handling transactions

Transaction is a set of one or more statements executed as a unit. The intent is that multiple statements which are part of a unit are executed together to make it meaningful. This article provides a quick introduction to handling transactions in JDBC. Here are some key points to remember when dealing with transactions using …

JDBC handling transactions Read More »

JDBC Database Access Examples

This article provides a list of key examples which we would commonly encounter when implementing a Java application requiring database access. For purpose of these examples the assumption is that PostgreSQL database is already setup and necessary database driver is downloaded and added to the CLASSPATH. Refer to this article JDBC Quick Start for a quick introduction …

JDBC Database Access Examples Read More »

Generics in Java

Generics is a key element in the Java programming language and a solid understanding is essential for any Java programmer. This article provides an introduction to the concepts around Generics in Java. Generics Introduction Generics provide the ability to create classes, methods and interfaces to be used with different types of data in a type-safe …

Generics in Java Read More »

Approaches to create threads

There are 2 approaches to create threads in Java either using a Runnable object or to Subclass Thread. Runnable object In this approach, the class implements Runnable interface which defines a single method run. The Runnable object is passed to the thread constructor. Using the Runnable object is the most general approach because the Runnable …

Approaches to create threads Read More »