Jetzt schauen wir uns mal an wie man die verschiedenen Variablen ausgeben kann:
public class halloVariablen {
public static void main (String[] args) {
String name = "Jana";
int alter = 27;
double groesse = 1.55;
System.out.println("Mein Name ist " + name + " ich bin " + alter + " Jahre alt" + " und bin " + groesse + " m gross ");
}
}
Das währe nun unsere Ausgabe:

English:
Now let's take a look at how to output the different variables:
public class helloVariables {
public static void main (String[] args) {
String name = "Jana";
int alter = 27;
double size = 1.55;
System.out.println("My name is " + name + " I am " + old + " years old" + " and am " + size + " m size ");
}
}
That would be our issue now: My name is Jana i´m 27 Jears old and im 1.55 m tall
Wir können auch mit Variablen rechnen hierzu mal ein Kleines Beispiel:
public class halloVariablen {
public static void main (String[] args) {
int wert1 = 6;
int wert2 = 7;
double wert3 = 3.8;
int ergebnis = wert1 * wert2 + (int)wert3; //Wenn wir so rechnen wollen müssen wir schauen das die Datentypen gleich sind.
//Wollen wir einen double Datentypen müssen wir den double Typ zu int casten.
// Das machen wir indem wir vor der double variable in Klammern int schreiben.
//In diesem fall wird beim casten einfach die Nachkommastelle nicht beachtet.
System.out.println("Das Ergebnis ist: " + ergebnis);
}
}

English:
We can also calculate with variables for this a small example:
public class helloVariables {
public static void main (String[] args) {
int value1 = 6;
int value2 = 7;
double value3 = 3.8;
int result = value1 * value2 + (int)value3; //If we want to calculate like this we have to make sure that the datatypes are the same.
//If we want a double datatype we have to cast the double type to int.
// We do this by putting int in brackets in front of the double variable.
// In this case the decimal place is ignored when casting.
System.out.println("The result is: " + result);
}
}
The result is : 45
Wenn wir aber wollen das die Nachkommastellen beachtet werden dann muss die Variable ergebnis ein double sein.
double ergebnis = wert1 * wert2 * wert3;
![]()
English:
But if we want the decimal places to be considered then the variable result must be a double.
double result = value1 * value2 * value3;
The rsult is: 159.6