-
Notifications
You must be signed in to change notification settings - Fork 2
Tag 01 Programmierung # 1 Java
Java was created in 1995 by Oracle (started by Sun) on the basis of C++ in order to create a platform-agnostic programming language which would run similarly on different devices.
Think of variables as boxes to contain a value of a defined type
camelCase is conventional for variable naming in Java
int number;
int number = 7;
= sets the value of the variable
Data type defines the content type, which the value of the variable may be of
Primitive datatypes can be in particular: integral/whole numbers e.g.:
- byte
- short
- int -
- long
fractional numbers (floating-point literals) e.g.:
- float - always set f after a number while initialsing
- double
conditions e.g.:
- boolean -
trueorfalse
texts e.g.:
- String - string needs
""; strings may be added with+ - char - character needs
''
boolean booleanTrue = true;
boolean booleanFalse = false;
System.out.println(booleanTrue && booleanFalse) // is falseLogical And
-
true && false= false -
true && true= true -
false && true= false
-
==equal to -
!=not equal to -
>greater than -
>=greater than or equal to -
<less than -
<=less than or equal to
An array is a data structure of multiple variables of the same type
int[] array = new int[3];
// 'new' declaration of a new instance of an array with exactly three integers
array[0] = 1
array[1] = 2
array[2] = 3To set up a new java project in IntelliJ IDEA follow these steps:
- File - Empty Project
- Enter name
Newly started project contains a precoded method main
public class Main {
// main method is regularly run on the start
public static void main(String[] args) {
// here is the playground
System.out.println("Hello world!");
}
}run Main.java to execute