Skip to content

Instantly share code, notes, and snippets.

@TPei
Created October 15, 2014 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TPei/7854726ba8a401b4c7b9 to your computer and use it in GitHub Desktop.
Save TPei/7854726ba8a401b4c7b9 to your computer and use it in GitHub Desktop.
Java DEMO Zuweisungen
public class A_Zuweisungen {
public static void main(String[] args) {
// Deklarierung (ohne Wert)
int a;
int b, c, d;
// Initialisierung (mit Wertzuweisung)
a = 7;
int e = 10;
int f = 11;
// Variablen ist jederzeit ein neuer Wert zuweisbar
a = 11;
e = 12;
f = 13;
// mathematische Ausdrücke (+, -, /, *)
// werden enstsprechend der gaengigen mathematischen Regeln
// Punkt vor Strich, Klammer zu erst
// ausgewertet
b = 1 + e; // b => 13
c = a + f; // c => 24
d = 10 + 12 + e; // d => 34
// Wertausgabe in die Konsole
System.out.println("a: " + a + ", b: " + b + ", c: " + c + ", d: " + d + ", e: " + e + ", f: " + f);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment