wiki:JavaProgramming

Programming in Java

Please choose a learning level that corresponds to your experience in Java or another programming language (or lack thereof).

If you have never programmed before,

see Java as Your First Language.

If you have programmed using high-syntax programming language with object-orientation such as C++ (using OOP),

see Java as Your Second Language From a High-Syntax, Object-Oriented Language.

If you have programmed before, but using a simpler, abstracted language, such as Go or Python without classes, without object-orientation,

see Java as Your Second Language From a Low-Syntax, Abstracted Language w/o Object-Orientation.

If you have already learned the basics of Java,

see Advanced Java After Having Already Learned Java Syntax & Control Structures.

If you think you are a master in Java and computer science in general,

try Incredibly Advanced Java Structures, Techniques, and Design.

If you think you are the absolute best programmer in the world,

try again.

Java as Your First (Programming) Language

Introduction to Computer Hardware

For those of you starting out in the programming world, a brief description of the hardware of a computational machine is necessary.

See here? to read about the JVM and how Java compiles.

Java as Your Second (Programming) Language

From a High-Syntax, Object-Oriented Language

From a Low-Syntax, Abstracted Language w/o Learning Object-Orientation

Advanced Java After Having Already Learned Java Syntax & Control Structures

If you have already learned object oriented concepts, skip to the next section.

Object-Oriented Programming Concepts

These sections assume that you have read through the Introduction to Object-Oriented Programming page.

Encapsulation

Encapsulation is the idea that a class contains both fields (variables and constants), which show state, and methods, which dictate the functionality. Encapsulation also makes clear the idea that methods and fields are tightly bound to the object that they represent, and should be implemented as such.

Nearly all fields should be assumed to be private unless there is a very good reason to make them otherwise.

Methods are either generally public or private, depending on the use. Assume that the client would like it to be as easy as possible for them, so provide functionality that is complex enough to be useful, but also not so complicated to use and understand.

Inheritance

Oftentimes, classes will reuse code from another class and build on it. For example, there might a generic Car class, which several others might subclass and create additional functionality in their classes, which might be Porsche and Mustang.

Polymorphism

The Ternary Operator

When assigning a value to a variable, sometimes, if the value being assigned is subject to a condition, the ternary operator will simplify code, save space, and enhance comprehension, but only when used properly. The operator transforms this:

int integer;

if (newIntegerWanted())
  integer = randomInteger();
else
  integer = 0;

to:

int integer = newIntegerWanted() ? randomInteger() : 0;

Abstract Classes

Choosing between an abstract class, an interface, or standard inheritance

Super Advanced Java Structures, Techniques, & Design

Last modified 7 years ago Last modified on Jan 29, 2015, 1:02:42 PM