Chapter 3. Writing Methods
When you write a program, you perform two basic tasks: you define your data structures, then define the operations to perform on the data. In the Java virtual machine, the fundamental unit of operation is the instruction, which causes the JVM to perform a simple operation such as adding two numbers or retrieving a value from the heap. Each instruction by itself performs only a tiny piece of an overall task.
Instructions are collected into a unit called a method. The instructions in a method work together to perform a task such as multiplying matrices or drawing a three-dimensional figure on the screen. Methods may have just a few instructions or several thousand. A method has the ability to repeat parts of its code and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access