Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 9. Object Lifetime > Field Initializer Expressions

9.8. Field Initializer Expressions

Initialization of fields can be specified in field declaration statements using initializer expressions. The value of the initializer expression must be assignment compatible to the declared field (see Section 5.5, p. 169 and Section 7.9, p. 320). We distinguish between static and non-static field initializers.

class ConstantInitializers {
  int minAge = 12;                    // (1) Non-static
  static double pensionPoints = 10.5; // (2) Static
  // ...
}


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint