diff options
author | Adam Bard <github@adambard.com> | 2015-10-21 21:54:45 +0800 |
---|---|---|
committer | Adam Bard <github@adambard.com> | 2015-10-21 21:54:45 +0800 |
commit | 51aad2ff341b3318ab9e0d2345f4aa51ab2bbae1 (patch) | |
tree | f96913a2e2e2705fe82cc5e3eb92917ff1f326f8 | |
parent | b89c4a82c81ce8b26c14cb5fee8fc97eeb4e9ec1 (diff) | |
parent | 707551a1436daa163c60c8bf7496d17c2a030f32 (diff) |
Merge pull request #1713 from perlilja/master
[java/en] Static code block
-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() { |