Please enable javascript in your browser.
Page
of
0
Fundamentals of Java programming
,
Book
Ogihara, Mitsunori
Springer International Publishing AG
2018
Cataloging brief
Fundamentals of Java programming
,
Book
Ogihara, Mitsunori
Springer International Publishing AG
2018
Find in content
sort by
page number
page score
Bookmark
Preface
(6)
Contents
(7)
List of Figures
(12)
List of Tables
(14)
Part I Programming Basics
(15)
1 ``Hello, World!''
(16)
1.1 The Programming Environment for Java
(16)
1.1.1 The Java Virtual Machine (JVM)
(16)
1.1.2 Changing Folders in a Command Line Interface
(17)
1.1.3 Source Codes, Bytecodes, and Compilation
(19)
1.2 The First Program, ``Hello, World!''
(20)
1.2.1 Methods and Their Declarations
(22)
1.2.2 System.out.println and System.out.print
(23)
1.2.3 Spacing in the Source Code
(24)
1.2.4 Commenting
(24)
1.2.5 Errors
(26)
1.3 Using Multiple Statements
(28)
1.3.1 System.out.println and System.out.print (Reprise)
(28)
1.3.2 Printing Multiple-Line Texts on the Screen
(29)
1.3.3 Escaping Characters
(31)
1.3.4 Printing Shapes
(33)
Summary
(36)
Exercises
(37)
2 Using Data for Computation
(41)
2.1 Data
(41)
2.1.1 Data and Their Taxonomy
(41)
2.1.2 Number Literals
(42)
2.1.3 Variable Declarations
(44)
2.1.4 Assigning Values to Variables
(45)
2.2 The Primitive Data Types
(47)
2.3 Using Variables for Computation
(49)
2.3.1 Quarterbacks Program (Reprise)
(49)
2.3.2 Number Arithmetics
(51)
2.3.2.1 Number Operations
(51)
2.3.2.2 Evaluation of Formulas
(53)
2.3.2.3 Mixing Different Number Types in a Formula
(57)
2.3.3 Computing the Body-Mass Index
(58)
2.3.4 Sum of Integers from 1 to 100 à la Gauss
(60)
2.3.4.1 Truncation of Real Numbers
(61)
2.3.5 Simplified Expressions
(63)
2.4 An Introduction to the String Data Type
(68)
2.4.1 The String Data Type
(68)
2.4.2 String Concatenation
(71)
2.4.2.1 Concatenating Two String Data
(71)
2.4.2.2 Concatenating String Data with Other Types of Data
(73)
Summary
(74)
Exercises
(75)
3 Reading Keyboard Input
(80)
3.1 Class Scanner
(80)
3.1.1 Importing Source Codes
(80)
3.1.2 The Instantiation of a Scanner Object
(81)
3.2 Reading Data with a Scanner Object
(82)
3.3 Reading Input from the Keyboard
(88)
Summary
(91)
Exercises
(92)
4 Decomposing Code into Components
(97)
4.1 Procedural Decomposition
(97)
4.1.1 Printing Rectangles
(97)
4.1.2 Printing Quadrangles
(102)
4.1.3 ``Old MacDonald Had a Farm''
(105)
4.1.4 A General Strategy for Procedural Decomposition
(111)
4.2 Using Multiple Program Files
(113)
Summary
(115)
Exercises
(115)
5 Passing Values to and from Methods
(119)
5.1 Passing Values to Methods
(119)
5.1.1 Methods That Work with Parameters
(119)
5.1.2 Method Overloading
(125)
5.2 Receiving a Value from a Method
(129)
5.3 Class Math
(134)
5.3.1 Mathematical Functions in Java
(134)
5.3.2 Mortgage Calculation
(141)
Summary
(146)
Exercises
(147)
6 Conditions and Their Use for Controlling the Flow of Programs
(152)
6.1 Condition and Its Evaluation
(152)
6.2 The If Statements
(158)
6.2.1 If
(158)
6.2.2 Else
(165)
6.2.3 If-Else Inside If/Else
(167)
6.2.4 Truncation of Conditional Evaluations
(171)
Summary
(172)
Exercises
(173)
Part II Loops
(179)
7 For-Loops
(180)
7.1 Using For-Loops for Repetition
(180)
7.2 Iteration
(187)
7.2.1 Simple Iteration
(187)
7.2.2 Iteration with an Auxiliary Variable
(193)
7.3 Double For-Loops
(194)
7.4 Computing the Maximum and Minimum in a Series of Numbers
(200)
7.5 A Betting Game
(202)
7.5.1 For-Loops with Skipped Execution
(202)
7.5.2 The Statements continue and break
(206)
7.6 Computing the Fibonacci Sequence
(208)
Summary
(209)
Exercises
(209)
8 Formatted Printing Using printf
(217)
8.1 General Rules for printf
(217)
8.2 Formatted Printing of String Data
(217)
8.3 Formatted Printing of Integers
(220)
8.4 Formatted Printing of Floating Point Numbers
(222)
8.5 Printing the Fibonacci Sequence (Reprise)
(224)
Summary
(227)
Exercises
(227)
9 Classes String and StringBuilder
(231)
9.1 Methods for Obtaining Information from String Data
(231)
9.2 Methods for Comparing String Data with Another
(234)
9.2.1 The Equality Test and the Comparison in Dictionary Order
(234)
9.2.2 The Prefix and Suffix Tests
(236)
9.3 Methods for Searching for a Pattern in a String Data
(237)
9.4 Methods for Creating New String Data from Another
(240)
9.4.1 String.format
(243)
9.5 Class StringBuilder
(243)
Summary
(245)
Exercises
(245)
10 The Switch Statements
(251)
10.1 The Syntax of Switch Statements
(251)
10.2 Using a char Data in a Switch-Statement
(258)
10.3 Using a String Data in a Switch Statement
(263)
Summary
(264)
Exercises
(265)
11 While-Loops and Do-While Loops
(268)
11.1 Using While-Loops
(268)
11.1.1 The Syntax of While-Loops
(268)
11.1.2 Summing Input Numbers Until the Total Reaches a Goal
(270)
11.1.3 Integer Overflow
(271)
11.1.4 Vending Machines
(273)
11.1.5 The Collatz Conjecture
(275)
11.1.6 Covnerting Decimal Numbers to Binary Numbers
(278)
11.1.7 Infinite Loops and Their Termination
(281)
11.2 Using Do-While Loops
(281)
11.2.1 The Syntax of Do-While Loops
(281)
11.2.2 ``Waiting for Godot''
(282)
11.2.3 Converting Decimal Numbers to Binary Numbers (Reprise)
(283)
11.3 CTRL-D
(283)
11.4 Approximating the Square Root of a Real Number
(288)
Summary
(292)
Exercises
(292)
Part III Arrays and Objects
(298)
12 Arrays
(299)
12.1 Arrays
(299)
12.1.1 The Structure of an Array
(299)
12.1.2 Computing the Number of Occurrences
(300)
12.1.2.1 Computing Distributions
(300)
12.1.2.2 Simulating the Action of Throwing Two Dice
(304)
12.1.2.3 Initialization of an Array
(307)
12.1.3 ArrayIndexOutOfBoundsException
(307)
12.2 Relative Indexing
(309)
12.2.1 The Concept of Relative Indexing
(309)
12.2.2 Calculating the BMI for a Range of Weight Values
(310)
12.2.3 Counting the Occurrences of Characters
(311)
12.3 Arrays of boolean Data
(314)
12.4 Using Multiple Arrays
(318)
12.5 String Methods That Return an Array
(321)
Summary
(322)
Exercises
(322)
13 The Class Arrays and Resizing Arrays
(328)
13.1 The Class Arrays
(328)
13.2 Reordering Elements in an Array
(332)
13.2.1 Reversing the Order of Elements
(335)
13.2.2 Cyclic Shifting
(335)
13.3 Modifications of an Array That Require Resizing
(339)
13.3.1 Insertion and Deletion
(339)
13.3.2 Adjoining Two Arrays
(344)
13.4 args
(345)
13.5 Searching for an Element in an Array
(346)
13.5.1 Sequential Search
(346)
13.5.2 Binary Search
(347)
13.6 Arrays with Capacity and Size
(348)
Summary
(354)
Exercises
(355)
14 Multidimensional Arrays
(360)
14.1 Rectangular Arrays
(360)
14.1.1 Defining Multi-Dimensional Arrays
(360)
14.1.2 Summing the Elements in Subsequences
(361)
14.2 Jagged Arrays
(364)
Summary
(367)
Exercises
(367)
15 Class File
(370)
15.1 Class File
(370)
15.1.1 The File Path and the Instantiation of a File Object
(370)
15.1.2 File Methods
(371)
15.1.3 Exception Handling
(373)
15.1.3.1 Error Handling Imposed by the Compiler
(373)
15.1.3.2 ``Throwing'' a Run-Time Error
(373)
15.1.3.3 ``Catching'' a Run-Time Error
(374)
15.1.3.4 A Demonstration of Try-Catch
(375)
15.1.4 File Listing
(379)
15.2 Using Scanner Objects to Read from Files
(381)
15.3 Using PrintStream to Write to Files
(387)
Summary
(389)
Exercises
(390)
16 Designing Object Classes
(394)
16.1 Packaging a Group of Data as an Object
(394)
16.1.1 The Position of a Game Piece
(394)
16.1.2 Private Instance Variables and the toString Method
(398)
16.1.3 Using Constants in an Object Class
(401)
16.1.4 Information Hiding
(405)
16.2 An Object Class Representing a Bank Account
(411)
16.3 Array with Capacity and Size (Reprise)
(418)
Summary
(422)
Exercises
(422)
Part IV Advanced Concepts
(427)
17 Interfaces, Inheritance, and Polymorphism
(428)
17.1 Interface
(428)
17.1.1 The Structure of an Interface
(428)
17.1.2 A Simple Pizza Application
(428)
17.1.2.1 A Simple Pizza Class
(428)
17.1.2.2 Using an Interface as a Data Type
(430)
17.1.2.3 Instance Variables and Constructors
(431)
17.1.2.4 Reading Data
(432)
17.1.2.5 Writing Data
(432)
17.1.2.6 Adding a Pizza to the List
(433)
17.1.2.7 Removing a Pizza from the List
(433)
17.1.2.8 Viewing the Elements of the List
(434)
17.1.2.9 The Pizza Collection Main Class
(434)
17.2 Subclasses and Superclasses
(436)
17.2.1 Extending Existing Classes and Interfaces
(436)
17.2.2 Writing Extensions
(438)
17.2.2.1 Writing a Subclass
(438)
17.2.2.2 A Class for a Collection of PizzaComplex Data
(441)
17.3 Polymorphism
(446)
17.4 Boxed Data Types
(447)
17.5 Interface Comparable
(448)
Summary
(453)
Exercises
(454)
18 Generic Class Parameters and the Java Collection Framework
(457)
18.1 ArrayList
(457)
18.1.1 Maintaining a Collection of Merchandise Items
(457)
18.1.2 The Class for Merchandise Item
(457)
18.1.3 The Comparator Class
(458)
18.1.4 The Collection of Merchandise Items That Uses ArrayList
(459)
18.1.4.1 ArrayList
(459)
18.1.4.2 The Instance Variables, the ``Getters'', and the ``Setters''
(460)
18.1.4.3 The File Read/Write
(462)
18.1.4.4 The Sorting Methods
(462)
18.1.5 The Main Class
(463)
18.1.5.1 The Method for Printing Prompt
(463)
18.1.5.2 The Method main
(464)
18.1.5.3 Adding and Removing
(464)
18.1.5.4 Viewing and Sorting
(465)
18.1.5.5 Making Changes
(466)
18.1.5.6 File Read/Write
(467)
18.2 The Dynamic Maintenance of the Largest K Values
(470)
18.3 The Java Collection Framework
(473)
18.3.1 The Framework
(473)
18.3.2 Some Classes from the Framework
(475)
18.3.3 A Demonstration
(477)
Summary
(481)
Exercises
(481)
19 Online and Recursive Algorithms
(485)
19.1 Online Algorithms
(485)
19.1.1 The Definition of Online Algorithms
(485)
19.1.2 Computing Recurrences
(486)
19.1.3 Computing the Factorial Function
(489)
19.2 Recursive Algorithms
(492)
19.2.1 Computing the Factorial Function Recursively
(492)
19.2.2 The Greatest Common Divisor of Two Integers
(497)
19.2.3 The Tower of Hanoi
(500)
19.2.3.1 The Problem Statement
(500)
19.2.3.2 Our Solution
(500)
19.2.3.3 Will the World End Soon?
(503)
Summary
(504)
Exercises
(504)
Index
(506)