Abstract
When we are writing a program, we may have a piece of information that will need to be referred to from other places in our program. Values and variables are used for this. They are defined using the keywords val and var, respectively. We can think of vals and vars as boxes containing items of data. A var is a box from which the data may be removed and replaced with some other data item. With a val, however, the data item is set once and can never be replaced.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2021 The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature
About this chapter
Cite this chapter
Lavers, T. (2021). Values and Variables. In: Learn to Program with Kotlin. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-6815-5_6
Download citation
DOI: https://doi.org/10.1007/978-1-4842-6815-5_6
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-6814-8
Online ISBN: 978-1-4842-6815-5
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)