diff options
author | Per Lilja <perlilja@gmail.com> | 2015-10-21 13:29:59 +0200 |
---|---|---|
committer | Per Lilja <perlilja@gmail.com> | 2015-10-21 13:29:59 +0200 |
commit | 707551a1436daa163c60c8bf7496d17c2a030f32 (patch) | |
tree | 8e42aa5228ce5a24bd4bc3b8656401dad7156f2b /java.html.markdown | |
parent | 3f8b067a0cace44bb43bdd08561b0efc747fb26c (diff) |
Added text about static code block.
Diffstat (limited to 'java.html.markdown')
-rw-r--r-- | java.html.markdown | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/java.html.markdown b/java.html.markdown index 38c9e490..aae64ccf 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -450,6 +450,17 @@ class Bicycle { protected int gear; // Protected: Accessible from the class and subclasses String name; // default: Only accessible from within this package + static String className; // Static class variable + + // Static block + // Java has no implementation of static constructors, but + // has a static block that can be used to initialize class variables + // (static variables). + // This block will be called when the class is loaded. + static { + className = "Bicycle"; + } + // Constructors are a way of creating classes // This is a constructor public Bicycle() { |