Java 101

  1. Local Setup
  2. Archetype – A New Project
  3. Basics
    1. Packages
    2. Imports
    3. Variables
    4. Methods
    5. Primitives
    6. Conditionals
    7. Looping
    8. Error / Resource Handling
    9. Collections
    10. Unit Testing
    11. Strings
  4. Building a Java Project
    1. Maven
    2. Ant
  5. Coding Conventions
  6. Configuration
  7. Documentation
  8. Object Oriented Concepts – Classes, Enums, Interfaces
  9. Other

Learn the basics of Java programming. Unlike the category listing on the left side of the page, which is alphabetized, this page contains list of posts that you may want to review as your Java learning progresses in a possible ordering.

Although unit testing is not first in this list, it is quite important as you learn and grow. For more about why many of these posts include unit testing and work in small loops, please see: Test Driven Development (TDD)

Local Setup

Setup that may be needed on your local machine (desktop, or laptop) in order to start coding in Java:

Archetype – A New Project

Creating a new Java project from a template (archetype):

Basics

Packages

Groupings / folders of Java files:

Imports

Using other Java classes or methods in your Java file:

Variables

Java fields or local variable syntax / conventions:

Methods

Syntax / conventions for Java functions / methods:

Primitives

Java primitives, such as booleans, ints, longs, doubles, floats:

Conditionals

Conditional logic structures:

Looping

Executing a given block of code multiple times:


Error / Resource Handling

What to do when unexpected / undesired scenarios occur? How do we handle resources that need to be closed even when errors occur?

Collections

Groups of related objects in a collection / array together.

Unit Testing

JUnit is one framework for unit testing Java code.

Strings

Java Strings are immutable; once created they cannot be changed. Any changes to a Java String requires a new Java String to be created and the old String hangs around in memory until garbage collection eventually occurs. Therefore, Strings have special handling in Java to avoid performance, memory and other pitfalls.

Building a Java Project

Maven

Maven is often used to build Java projects. In Maven, we do not store dependencies with the Java code. Instead, there are Maven repositories which house these artifacts and we download them to a local Maven repository cache as they are needed.

In Maven, plugins are configured in an XML file (pom.xml) to say how we want the build to behave.

Ant

Ant is a lower level build approach than Maven, meaning that less of the build work is done for you out of the box. There may be one-off situations in which we need do dip down and use an Ant task within a higher-level build. However, I would recommend using a higher level (more abstract) approach to building Java projects in general.

For example, an Ant build doesn’t have any dependency download mechanism build into the framework. Therefore, in code bases I have worked with that used Ant for the build, they often fell into the pitfall of storing dependencies in the same repository (repo) as the source code. This can slow down nearly all interactions with that code repo for even simple things, like asking if your local git clone is up-to-date with the remote git repo.

Coding Conventions

Approaches that have evolved over time, rather than something built into the syntax of Java code.

Note: If this section is empty, it may be due to these posts also being included in other sections of this page. If so, see Coding Conventions page for a full listing.

Configuration

Ways in which configuration can be passed into a Java application.

Documentation

We need to document designs and details about our code, so that our teammates, our future selves, or those consuming our project as a dependency can understand how to interact with the code successfully.

Object Oriented Concepts – Classes, Enums, Interfaces

Java is an object oriented language. Java classes, enums (enumerations) and interfaces represent objects in our application’s domain:

Other

Other Java posts that did not fall into the categories above, if any: