Chapter 1

A Brief Introduction to Java

Before beginning our study of data structures, we take a quick tour of the main features of the Java programming language. More advanced features of Java will then be introduced as they are needed. This chapter assumes that you have some programming experience but not necessarily in Java.

A current Java Development Kit (JDK) is required to develop software in Java. All of the examples in this text were written using Java SE 7.

1.1 Basics

We begin with an example that computes factorials in Listing 1.1.

Listing 1.1: Factorial

 1 public class NumericFunctions {
 2 public static int factorial(int n) {
 3  int result = 1;
 4  for (int i = 2; i <= n; i++) {
 5  result *= i;
 6 }
 7  return result;
10 public ...

Get A Concise Introduction to Data Structures using Java now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.