Skip to main content

Creating Domain Classes

  • Chapter
  • First Online:
Foundational Java

Part of the book series: Texts in Computer Science ((TCS))

  • 3014 Accesses

Abstract

This chapter opens with some discussion of object-oriented concepts such as information hiding and the encapsulation of state and behavior inside objects. This is followed by an illustration of how classes and their fields and methods are represented in the Unified Modeling Language (UML). Subsequent code examples show how new domain classes can be created in Java, along with their fields, methods and constructors, and how Eclipse provides automated support for some of these tasks. The overloading of the constructor method to provide ways of creating objects with different sets of arguments is also explained. Further discussion of encapsulation covers constructor chaining and the four visibility modifiers; “public”, “private”, “default” and “protected”. The chapter goes on to show how the Javadoc tool can be used to generate HTML documentation for user-created classes, either from within Eclipse or from the command line. This includes some coverage of special Javadoc tags that can be added to comment blocks to provide additional information in the generated Javadoc. The final part of the chapter explores more specific aspects of creating classes including static fields and methods, JavaBean components, reflection and the “var” keyword, which can be used with local variables to allow the compiler to infer their data types.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 49.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 64.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 89.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to David Parsons .

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Parsons, D. (2020). Creating Domain Classes. In: Foundational Java. Texts in Computer Science. Springer, Cham. https://doi.org/10.1007/978-3-030-54518-5_6

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-54518-5_6

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-54517-8

  • Online ISBN: 978-3-030-54518-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics