JavaExamples
Java Syntax
Syntax ExplainedJava Comments
Single-line comment before a line of codeSingle-line comment at the end of a line of codeMulti-line comment
Comments ExplainedJava Variables
Create a string variableCreate an integer variableCreate a variable without assigning the value, and assign the value laterOverwrite an existing variable valueCreate a final variable (unchangeable and read-only)Combine text and a variable on displayAdd a variable to another variableDeclare many variables of the same type with a comma-separated list
Variables ExplainedJava Data Types
A demonstration of different data types in JavaCreate a byte typeCreate a short typeCreate an int typeCreate a long typeCreate a float typeCreate a double typeCreate a boolean typeCreate a char typeCreate a String type
Data Types ExplainedJava Type Casting
Type Casting ExplainedJava Operators
Addition operatorSubtraction operatorMultiplication operatorDivision operatorModulus operatorIncrement operatorDecrement operatorAssignment operatorComparison operatorLogical operator
Operators ExplainedJava Strings
Create a stringQuotes inside a stringFind the length of a stringUsing methods to convert strings to uppercase and lowercaseFinding a string in a stringString concatenationIf you add a number and a string, the result will be a string concatenation
Strings ExplainedJava Math
Math.max(x,y) - return the highest value of x and yMath.min(x,y) - return the lowest value of x and yMath.sqrt(x) - return the square root of xMath.abs(x) - return the absolute (positive) value of xMath.random() - return a random number between 0 and 1
Math ExplainedJava Booleans
Create a boolean typeFind out if an expression is true or falseUse the "equal to" operator to evaluate a boolean expression
Booleans ExplainedJava If...Else (Conditions)
If...Else ExplainedJava Switch
Switch ExplainedJava Loops
Loops ExplainedJava Arrays
Create and access an arrayChange an array elementFind the length of an arrayAccess an arrayLoop through an arrayLoop through an array with for-eachMultidimensional arrayLoop through a multidimensional array
Arrays ExplainedJava Methods
Create and call a methodCall a method multiple timesMethod with parametersMethod with multiple parametersReturn valueA method with if...elseMethod overloadingRecursionRecursive function with a halting condition
Methods ExplainedJava Classes and Objects
Create a class and an object of a classCreate multiple objects of a classAccessing class attributes (variables)Modify attributesOverride existing attribute valuesMultiple attributesCreate a class methodMethod with parametersAccess class methods with an objectCreate a class constructorConstructor with parameters
Classes and Objects ExplainedJava Modifiers
Public classDefault classPublic attributesPrivate attributesDefault attributesProtected attributesFinal classAbstract class with abstract methods
Modifiers ExplainedJava Encapsulation
Encapsulation ExplainedJava Packages
Packages ExplainedJava Inheritance
Inheritance ExplainedJava Inner Classes
Inner classPrivate inner class (error when trying to access it from an outside class)Static inner classAccess outer class from inner class
Inner Classes ExplainedJava Abstraction & Interfaces
Interfaces ExplainedJava Enums
Create an enum with a group of constantsAn enum inside a classAn enum in a switch statementLoop through an enum
Enums ExplainedJava User Input
User Input ExplainedJava Dates
Dates ExplainedJava ArrayList
Create an ArrayListAccess an item in an ArrayListRemove an item from an ArrayListRemove all items from an ArrayListGet the size of an ArrayListLoop through an ArrayListLoop through an ArrayList with for-eachCreate an ArrayList that should store numbers (integers)
ArrayList ExplainedJava HashMap
Create a HashMapAccess an item in a HashMapRemove an item from a HashMapRemove all items from a HashMapGet the size of a HashMapLoop through a HashMapCreate a HashMap that should store String keys and Integer values
HashMap ExplainedJava HashSet
Create a HashSet and add items to itCheck if an item exists in a HashSetRemove an item from a HashSetRemove all items from a HashSetGet the size of a HashSetLoop through a HashSetCreate a HashSet that should store Integer values
HashSet ExplainedJava Iterator
Iterator ExplainedJava Wrapper Classes
Create an ArrayList that should store numbers (integers)Create wrapper objectsUsing wrapper methodsConvert wrapper objects to strings
Wrapper Classes ExplainedJava Exceptions (Try...Catch)
Exceptions ExplainedJava Regular Expressions
Regular Expressions ExplainedJava Threads
Running a thread by extending the thread classRunning a thread by implementing the Runnable interfaceConcurrency problemsAvoid concurrency problems
Threads Explained