Some tests on variable initialization

xiaoxiao2021-03-05  25

The following is an error message that test code and variables are not initiated.

Public class testinit {

// The following error occurs, the program cannot be compiled

// The constructor is initialized by default, for NULL

PRIVATE STRING TEST_INSTANCE;

// If you don't initialize this, you must initialize in the system.

/ / Otherwise, there will be "The Blank Final Field Test_Final May Not Have Been Initialized" error

PRIVATE FINAL STRING TEST_FINAL;

/ / Must be initialized when declaring, otherwise there will be the following error

// the blank final field test_static May Not Have Been Initialize

Public static factory string test_static = "static";

Testinit () {

/ / Can also be initialized in the system

Test_final = "final";

}

// Method within the method

PUBLIC VOID TEST_METHOD () {

// Variable does not initialize, there will be the following error in use

// "THE LOCAL VARIABLE TEST_IN_METHOD MAY NOT HAVE BEEN Initialized"

String test_in_method;

}

}

转载请注明原文地址:https://www.9cbs.com/read-33241.html

New Post(0)