Skip to content

Latest commit

 

History

History

java

Java challenges

A collection of programming challenges solved using Java

Introduction

With this part of the Challenges project, I provide solutions to common programming challenges in Java.

Below, I first give an overview of the challenges that I have solved so far. I then provide some background information on Java and the tools I used, namely, Bash, IntelliJ IDEA and Maven.

1. Overview

Currently, Java solutions are available for the following challenges, categorized according to the tools I used.

1.1 Command-line projects

I solved the challenges in this section using the command line but without a build tool.

1.2 IntelliJ IDEA projects

I solved the following challenges using IntelliJ IDEA. For some challenges, I did not use a build tool (manual). For others, I used Maven.

1.2.1 Manual

1.2.2 Maven

2. Background

In this section, I provide some background information on Java and the tools I used to solve the above-mentioned programming challenges, namely, Bash, IntelliJ IDEA and Maven.

2.1 Java

Java is an object-oriented programming language with a syntax similar to C and C++. As is the case for C and C++ code, Java code has to be compiled before it can be executed. C and C++ are, however, compiled into platform-specific machine code. Instead, Java compiles to platform-independent class files containing so-called bytecode. This bytecode can be executed on a platform of choice by a platform-specific Java virtual machine (JVM).

Most of the above-mentioned projects are configured to use Java 21, which is the latest long-term support (LTS) version of Java at the time of writing. These projects require the installation of the Java Development Kit (JDK) 21 or later. The installation of the latest JDK is described in the Installation section of Setting up a Java project using the command line.

2.2 Bash

Bash is a commonly used command-line interface for Unix-based operating systems. Bash can both interactively execute commands and run so-called shell scripts. MacOS and most Linux distributions come with Bash or a Bash-like shell. Windows users can obtain Bash by installing Git for Windows.

2.3 IntelliJ IDEA

IntelliJ IDEA is an integrated development environment (IDE) developed by JetBrains. This IDE supports Java and several other JVM languages and can be extended with plugins to retrieve support for other programming languages. IntelliJ IDEA has detailed online documentation, and its community edition can be downloaded and used for free.

IntelliJ IDEA makes it easy to configure code styles, automatic copyright notices, code inspection profiles, run configurations and more. The basic IntelliJ IDEA configuration used in the above-mentioned projects is described in the IntelliJ IDEA section of Setting up a Java project using IntelliJ IDEA. A step-by-step guide for setting up a Java project using IntelliJ IDEA can be found in the Create a new project section of IntelliJ IDEA’s online documentation.

2.4 Maven

Maven is a build tool that can be used to manage and build projects written in Java and other programming languages. The project object model, a file named pom.xml, is central to using Maven. In this file, the project properties can be set, build plugins can be configured, project dependencies can be defined, etc.

The basic Maven configuration used in the above-mentioned projects is discussed in the Maven section of Setting up a Java project using Maven and IntelliJ IDEA. A step-by-step guide for setting up a Maven project using IntelliJ IDEA can be found in the Maven section of IntelliJ IDEA’s online documentation. Maven does not need to be installed when used with IntelliJ IDEA.

License

Copyright © 2021–2023 Maurits Silvis

This source code package is subject to the terms and conditions defined in the GNU General Public License v3.0 or later.