Beruflich Dokumente
Kultur Dokumente
Lecture #2
Mary Ellen Foster
MaryEllen.Foster@glasgow.ac.uk
25 September 2019
http://rosettacode.org/wiki/Unicode_variable_names#Java
Identifier conventions
Standards and guidelines can differ on the details
Near-universal conventions
Classes start with a capital letter
Other identifiers start with a lower-case letter
Multi-word identifiers use “CamelCase”
ArrayIndexOutOfBoundsException
Constant values are written in ALL CAPS
Math.PI, Double.POSITIVE_INFINITY
Identifier scope
Block of statements is enclosed in System.out.print("2+1=");
curly braces { } int two = 2, three = two + 1;
Usually all statements in a block System.out.println(three);
have same indentation level
Unlike Python, this is not mandatory – ➢ 2+1=3
but strongly recommended!
A variable is in scope (accessible) …
From the point of declaration …
To the end of the enclosing block