1 PackageCom.mon11.day11;2 /** 3 * Class Description:4 * @authorAuthor: Chenyanlong5 * @versionCreation Date: November 11, 20176 */7 Public classStudent {8 /**9 * Static code block, when loading the class has started to execute only onceTen */ One Static { A -System.out.println ("I am a static code block! "); - } the /** - * Constructs a code block that executes when an object instance is created, and occurs only once before the constructor method is called - */ - { +System.out.println ("I am building blocks of code! "); - } + /** A * Construct method, execute only once when object instance is created at */ - PublicStudent () { -System.out.println ("I am the construction Method!") "); - } - - Public Static voidMain (string[] args) { inStudent student=NewStudent (); - } to}
Operating effect:
Static code block, construction code block, construction method Precedence (emphasis)-------Java Basics Summary