public student{

private static int MAXNUM=100;

static{

System.out.println(MAXNUM);

}

student(){

System.out.println(MAXNUM+2);

}

public static void main(String[] args){

System.out.println(MAXNUM+1);

}

}

out:

100
101

Class variables initialization order ,static Variable >static Static code area > Common variables > Common code area > Constructors , because static The particularity of the modifier ,static Methods are called passively

however !

static The code runs when the class loads , It's active , So if you need to execute a code when loading a class , Then we need to use the static code area at this time .

Java More about the role of static code

  1. Commonly used Java Analysis and comparison of static code analysis tools

    Commonly used Java Analysis and comparison of static code analysis tools brief introduction :  This paper first introduces the basis of static code analysis This concept and main technology , Then it introduces the existing 4 The mainstream Java Static code analysis tool (Checkstyle,FindBu ...

  2. [ Reprint ] Commonly used Java Analysis and comparison of static code analysis tools

    Reprinted from http://www.oschina.net/question/129540_23043 brief introduction :  This paper first introduces the basic concepts and main techniques of static code analysis , Then it introduces the existing 4 The mainstream Java Static generation ...

  3. 【 Reprint 】 Commonly used Java Analysis and comparison of static code analysis tools

    Excerpt from :http://www.oschina.net/question/129540_23043 Commonly used Java Analysis and comparison of static code analysis tools brief introduction :  This paper first introduces the basic concepts and main techniques of static code analysis , And then ...

  4. Commonly used Java Analysis and comparison of static code analysis tools

    For domestic static code testing tools Pinpoint hit Call! brief introduction This paper first introduces the basic concepts and main techniques of static code analysis , And then we introduce 4 There's an existing mainstream Java Static code analysis tool (Checkstyle,FindBugs ...

  5. [ original ]Java Introduction to static code checking tools

    [ original ]Java Introduction to static code checking tools One   What is static code checking ? Static code analysis means that there is no need to run the code under test , Just by analyzing or checking the syntax of the source program . structure . The process . Interface to check the correctness of the program , Find out the hidden errors and defects in the code , Such parameters ...

  6. java Static code block / Static attribute 、 Tectonic block 、 Constructor execution 、main Method 、 The order of normal code blocks

    java Static code block / Static attribute . Tectonic block . Constructor execution .main Method . The order of normal code blocks This is also an important test point in the written test , There is an output statement that lets you write the output . Theoretical knowledge : The static code block is : Belonging to the class , When the class loads ...

  7. java Static code blocks and spring @value And so on

      java Static code blocks and spring @value And so on The problem On the first code java Method @Value("${mf.cashost}") public static S ...

  8. JAVA What static code blocks do

    One In general , If some code has to be executed when the project starts , You need to use static code blocks , This kind of code is active ; It needs to be initialized when the project starts , Without creating objects Condition , When other programs call , You need to use static methods , such ...

  9. java Static code block 、 Common code

    Reference article :http://www.cnblogs.com/qinpengming/p/5227227.html Java There are often static blocks in , This is used for initialization before class generation , No matter what java also C++ In language ...

Random recommendation

  1. file NSKeyedArchiver De archiving NSKeyedUnarchiver And file management NSFileManager ( File operations )

    ========================== File operations ========================== One . file NSKeyedArchiver 1. The first way : Store a kind of data . // file ...

  2. noip2008 Double stack sorting

    Title Description  Description \(Tom\) Recently, I am studying an interesting sorting problem . As shown in the figure , adopt \(2\) Stack \(S_1\) and \(S_2\),\(Tom\) Hope to use the following \(4\) The first operation is to arrange the input sequence in ascending order ...

  3. Ehcache(01)—— brief introduction 、 Basic operation

    http://haohaoxuexi.iteye.com/blog/2112170 Catalog 1       CacheManager 1.1       Construction method construction 1.2       Static method construction 2  ...

  4. Git Common configuration and use

    Git: Is a distributed source code management tool ,Linux The code of the kernel is to use Git Managed, so it's strong , Very soon ,  and Vss/SVN Compare to Local Git Initialization configuration and its use : 1.  Initialize local Git library : open Git Bas ...

  5. To master completely KMP Algorithmic thought

    Document download page http://download.csdn.net/detail/yedeqixian/4209500      80 What are you talking about KMP The algorithm starts with an example , Let's be right KMP The basic idea of the book has been initially recognized ...

  6. linux journalctl command

    Catalog Help Output all log records matching (match) Save the log to a file Limit the maximum capacity that a log can take Check the log after a startup View logs for a specified period of time Simultaneous application match And time filter conditions Press unit ...

  7. MySQL Of Join Use

    stay MySQL( With 5.1 For example ) in , For table join syntax, see MySQL The official manual :MySQL The official manual -JOIN In the query , The syntax of the join is similar to SELECT select_expr FROM table_refere ...

  8. python The foundation 01 data type - Variable - Simple solution of operation

    python Data type of 1  Numbers Numbers are divided into integer types (int), Long integer (long), floating-point (float), The plural (complex) The more commonly used function of integer : >>> a=-4 >> ...

  9. 【Handler】Looper principle Detailed explanation Example summary

    Core knowledge points 1. Related nouns UI Threads : It's our main thread , The system is creating UI Thread will initialize a Looper object , It also creates a MessageQueue Handler: The function is to send and process information , ...

  10. C# Get the lunar date

    //C# Get the lunar date ///<summary> /// Instantiate a ChineseLunisolarCalendar ///</summary> private static ...