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
  • DownloadDownload
  • PrintPrint

12.4. Boxing Value Types

When working with value types, whether they are base data types, such as Integer, Long, or Double, or self-made structures, you never need to worry about the issues mentioned in the preceding sections, because you cannot inherit from value types.

There is one exception, however: all value types are derived from Object. While you can’t create an inheritance order based on a value type, Object and ValueType already exist in the inheritance order. This means that a variable of type Object should be able to refer to a value type. That sounds like a contradiction, but there’s a solution.


  

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