Archive for the ‘Learn Java’ Category

An array is a fundamental datastructure category, and a building block for more complex datastructures. In this second part of my Java 101 introduction to datastructures and algorithms, you will learn how arrays are understood and used in Java programming. I introduce the concept of an array and how arrays are represented in the Java language. Then you’ll learn about one-dimensional arrays and the three ways that you can introduce them to your Java programs. Finally, we’ll explore five algorithms … Read the rest

Parts 1 through 3 of this four-part series on developing Web services in Java SE first presented an overview of Web services and Java SE’s support for developing them. The series then focused on developing SOAP-based and RESTful Web services via this support. Part 4 wraps up this series by focusing on advanced topics.

This article first introduces Java SE’s SAAJ API for working with SOAP-based Web services at a lower level. It then discusses how to create a JAX-WS … Read the rest

Part 2 of this four-part series on Java SE Web services showed how to use the JAX-WS API to develop SOAP-based Web services. JAX-WS also supports RESTful-based Web services, which this article shows how to develop. It first defines and then builds and runs a library Web service, and next defines, builds, and runs a simple client that accesses this service.

Defining a library web service

The library Web service, which I’ve named Library, manages a library of books with … Read the rest

Datastructures and algorithms are essential to computer science, which is the study of data, its representation in memory, and its transformation from one form to another. In programming, we use datastructures to store and organize data, and we use algorithms to manipulate the data in those structures. The more you understand about datastructures and algorithms, the more efficient your Java programs will be.

This article launches a three-part series introducing datastructures and algorithms. In Part 1, you’ll learn what a … Read the rest

Exploring puzzling code to figure out why it doesn’t do what seems obvious is one way to improve your programming skills. In this post, I introduce you to various Java-oriented puzzlers from Jens Dietrich, Joshua Bloch and Neal Gafter, and myself.

Java Library Evolution Puzzlers

Q: What is the Java Library Evolution Puzzlers?

A: The Java Library Evolution Puzzlers is a survey focused on changing Java libraries and then recompiling their client programs’ source codes or running these clients unchanged … Read the rest

Understanding type compatibility is fundamental to writing good Java programs, but the interplay of variances between Java language elements can seem highly academic to the uninitiated. This two-part article is for software developers ready to tackle the challenge! Part 1 revealed the covariant and contravariant relationships between simpler elements such as array types and generic types, as well as the special Java language element, the wildcard. Part 2 explores type dependency in the Java Collections API, in generics, and in … Read the rest

JEP 266: More Concurrency Updates defines an interoperable publish-subscribe framework for reactive streams, enhancements to the java.util.concurrent.CompletableFuture class, and various other improvements. This post wraps up my series on Java 9’s other new enhancements by acquainting you with these concurrency enhancements.

Publish-subscribe framework for reactive streams

Java 9 includes a publish-subscribe framework for reactive streams. In this section, I first introduce the concept of reactive streams and then present this publish-subscribe framework.

Introducing reactive streams

Data processing has evolved from … Read the rest

The first half of this tutorial introduced you to regular expressions and the Regex API. You learned about the Pattern class, then worked through examples demonstrating regex constructs, from basic pattern matching with literal strings to more complex matches using ranges, boundary matchers, and quantifiers.

In Part 2 we’ll pick up where we left off, exploring methods associated with the Pattern, Matcher, and PatternSyntaxException classes. You’ll also be introduced to two tools that use regular expressions to simplify … Read the rest

Java’s character and assorted string classes offer low-level support for pattern matching, but that support typically leads to complex code. For simpler and more efficient coding, Java offers the Regex API. This two-part tutorial helps you get started with regular expressions and the Regex API. First we’ll unpack the three powerful classes residing in the java.util.regex package, then we’ll explore the Pattern class and its sophisticated pattern-matching constructs.

download
Get the complete source code for this article’s demo application. Created
Read the rest

JEP 102: Process API Updates enhances the java.lang.Process class and introduces the java.lang.ProcessHandle interface with its nested Info interface to overcome limitations that often force developers to resort to native code; for example, to obtain the native process ID (PID). This post introduces you to these upgrades.

Enhancing Process, and introducing ProcessHandle and ProcessHandle.Info

Java 9 adds several new methods to the abstract Process class that let you identify direct child or descendent processes, obtain this Process‘s PID, return … Read the rest