2

Here I have two ways to call System.LoadLibrary("XX.so"):

First way:

class SomeClass{
    static {
        System.LoadLibrary("XX.so");
    };

    public SomeClass(){
        ..
    };
}

The Other way:

class SomeClass{
        public SomeClass(){
            System.LoadLibrary("XX.so");
            ..
        };
    }

In most codes, I saw the first way is used. But second way also can run fine.

Do they have any difference between them ?

user2864740
  • 60,010
  • 15
  • 145
  • 220
I'm SuperMan
  • 653
  • 7
  • 20
  • 1
    The first runs in static class initialization. The latter runs each time an instance of the class is created.. – user2864740 Sep 14 '15 at 04:36
  • http://stackoverflow.com/questions/2420389/static-initialization-blocks , http://stackoverflow.com/questions/3499214/java-static-class-initialization – user2864740 Sep 14 '15 at 04:39
  • @user2864740 ,the only difference is the initialize time , and have no other effect. Is it ? Thanks for help – I'm SuperMan Sep 14 '15 at 05:31

0 Answers0