Skip to main content

Strong Typed Programming

  • Chapter
  • First Online:
Learn Java with Math
  • 1411 Accesses

Abstract

As we have learned at the beginning of this book in Part I, the Java programming language has defined the integer, double, Boolean, String, etc., as basic types. In Java, we cannot assign any value to a variable without defining the variable with a type beforehand. Only after a variable has been defined clearly by a type—for example, integer—are we then allowed to assign an integer value to it and start using it as an integer in the calculation. Once a variable's type is defined, it cannot be assigned a value with a different type, logically speaking. For instance, if a variable is defined as Boolean, it cannot be assigned an integer value. Otherwise, we will get a type mismatch compilation error.

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

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 16.99
Price excludes VAT (USA)
  • Compact, lightweight 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

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Ron Dai

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Dai, R. (2019). Strong Typed Programming. In: Learn Java with Math. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-5209-3_17

Download citation

Publish with us

Policies and ethics