Skip to main content Accessibility help
×
Hostname: page-component-8448b6f56d-m8qmq Total loading time: 0 Render date: 2024-04-18T12:23:35.427Z Has data issue: false hasContentIssue false

3 - Classes and objects in Java

Published online by Cambridge University Press:  08 January 2010

Clark S. Lindsey
Affiliation:
Space-H Services, Maryland
Johnny S. Tolliver
Affiliation:
Oak Ridge National Laboratory, Tennessee
Thomas Lindblad
Affiliation:
Royal Institute of Technology, Stockholm
Get access

Summary

Introduction

In Java the “class” is paramount. Essentially all coding resides within class definitions. Here and in the following chapters we develop the concepts and coding for classes and objects in Java.

For those new to object-oriented programming (OOP) the learning curve can be rather steep because several concepts must be understood before the overall picture comes into focus. The Web Course Supplements section for Chapter 3 offers additional introductory material to help get these concepts across.

Note that throughout the book we use the terms object and instance interchangeably.

Custom data types

In Chapter 2 we discussed Java primitive data types such as int, float, and boolean. Data of a given type means that memory is reserved for a value of that type and that only operations specific to that type can act upon the data. So, for example, a float value has 4 bytes of memory allocated for it with the sign, exponent, and significand bits arranged according to the representation discussed in Chapter 2. When an operation such as an addition or multiplication occurs upon a float value, the JVM executes floating-point operations that carry out the proper procedures for addition and multiplication with significands and exponents. For integer addition and multiplication the JVM executes a different set of operations unique to integer type data.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2005

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

References

Didier H. Besset, Object-Oriented Implementation of Numerical Methods: An Introduction with Java and Smalltalk, Morgan Kaufmann, 2001
Cay S. Horstmann and Gary Cornell, Core Java 2: Vol. 1 – Fundamentals, 6th edn, Sun Microsystems, 2002
Patrick Niemeyer and Joshua Peck, Learning Java, 2nd edn, O'Reilly, 2002
Monica Pawlan, Essentials of the Java Programming Language: A Hands-on Guide, March 1999, http://developer.java.sun.com/developer/onlineTraining/Programming/BasicJava1/
The Java Tutorial, Sun Microsystems, http://java.sun.com/docs/books/tutorial/

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×