Learning Java

 
class Coffee extends Beverage {

    public Coffee() {

    }

    public void addSugar(int cubes) {

        System.out.println("You added " + cubes + " sugar cubes.");

    }

    public static void main(String[] args) {
    Coffee myOrder = new Coffee();
    myOrder.addSugar(2);
    myOrder.isFull();
}
}

The void keyword indicates that no value should be returned by the method after it executes all the logic in the method. If we do want the method to return a value after it finishes running, we can specify the return type.
  1. The void keyword (which means "completely empty") indicates to the method that no value is returned after calling that method.
  2. Alternatively, we can use data type keywords (such as intchar, etc.) to specify that a method should return a value of that type.


Java is a programming language designed to build secure, powerful applications that run across multiple operating systems, including Linux, Mac OS X, and Windows. The Java language is known to be flexible, scalable, and maintainable.



Hello, World.

Hello, World in Java


Editing, compiling, and executing.

Compiling Hello, World in Java


Built-in data types.

Built-in types of data


Declaration and assignment statements.

Assignment statements


Integers.

int data type

Integer expressions


Floating-point numbers.

double data type

double expressions


Booleans.

boolean data type

Boolean operators


Comparison operators.

Comparison operators

Comparison examples


Printing.

System.out.print()


Parsing command-line arguments.

parsing Command-line arguments


Math library.

Math library API
The full 
java.lang.Math API.


Java library calls.

Expressions that use Java library methods


Type conversion.

Type conversion


Anatomy of an if statement.

anatomy of an if statement


If and if-else statements.

If-else statements


Nested if-else statement.

Nested if-else statements in Java


Anatomy of a while loop.

While loop


Anatomy of a for loop.

For loop


Loops.

While and for loops in Java


Break statement.

Break statement in Java


Do-while loop.

Do-while loop in Java


Switch statement.

Switch statement in Java


Arrays.

An array

Inline array initialization.

Inline initialization of arrays
Typical array-processing code.
Typical array-processing code

Two-dimensional arrays.

2D array
Inline initialization.
2D array inline initialization


Our standard output library.

Standard output API
The full StdOut API.
Anatomy of printf
Formatting codes for printf


Our standard input library.

Standard input API
The full StdIn API.


Our standard drawing library.

Standard drawing API
The full StdDraw API.


Our standard audio library.

Standard audio API
The full StdAudio API.


Redirection and piping.

Redirecting standard output                Redirecting standard input


Piping


Functions.

Anatomy of a function

Example functions


Libraries of functions.

Library abstraction


Our standard random library.

Standard random


Our standard statistics library.

Standard statistics


Using an object.

Using an object


Instance variables.

Anatomy of instance variables


Constructors.

Anatomy of a constructor


Instance methods.

Anatomy of an instance method


Classes.

Anatomy of a class


Object-oriented libraries.

Object-oriented library abstraction

Java's String data type.

String library API
The full java.lang.String API.
String operations

Java's Color data type.

Color library API
The full java.awt.Color API.


Our input library.

Input API
The full In API.


Our output library.

Output API
The full Out API.


Our picture library.

Picture API
The full Picture API.


Our stack data type.

Stack API
The full Stack API.


Our queue data type.

Queue API
The full Queue API.


Iterable.

Anatomy of an iterable


Our symbol table data type.

Symbol Table API
The full ST API.


Our set data type.

Set API
The full SET API.


Our graph data type.

Graph API