INDEX

       A

abandoned strings, 344–346

abstract classes, 19

constructors, 133, 136

creating, 23

implementation, 123

vs. interfaces, 25

overview, 21–22

abstract methods

inheritance, 93

overview, 45–48

subclass implementation, 106

access and access modifiers, 30–33

classes, 17–21

constructors, 135

encapsulation, 89

key points, 71

levels, 54

local variables, 42–43

overloaded methods, 111

overridden methods, 107–108

private, 34–36

protected and default members, 36–42

public, 33–34

static methods and variables, 151–154

add() method in ArrayList, 383

addition

compound assignment, 236

operator, 244

precedence, 257

ampersands (&)

bitwise operators, 251–252

logical operators, 252–255

precedence, 257

AND expressions, 252–255

angle brackets (<>) in generic code, 381

anonymous arrays, 372–373

append() method, 353–354

appending strings, 341–342, 353–354

applications, launching, 11–12

@argfiles options, 11

arguments

final, 44–45

overloaded methods, 111, 113

overridden methods, 108

vs. parameters, 49–50

super constructors, 137

variable argument lists, 49–50

arithmetic operators, 244–249

basic, 244–245

increment and decrement, 248–250

key points, 260–261

remainder, 245–246

string concatenation, 246–248

ArithmeticException class, 322

ArrayIndexOutOfBoundsException class, 306

description, 322

out-of-range array indexes, 369

superclass, 308–309

ArrayList class, 13–14

autoboxing, 384–388

basics, 380–381

diamond syntax, 388–389

duplicates, 383

key points, 401

methods, 382–384

uses, 379–381

arrays, 363

constructing, 364–367, 370–372

declaring, 57–59, 363–364, 370–372

default element values, 198–199, 202, 221

element assignments, 374–378

enhanced for loops, 292–293

indexes, 12, 368

initializing, 368–374

instanceof comparisons, 244

key points, 76, 399–400

length attribute, 350

reference assignments, 376–378

returning, 131

ASCII set, 53

AssertionError class, 316, 321

assignments

array elements, 374–378

compiler errors, 188–189

floating-point numbers, 188

key points, 220–221

object compatibility, 242

operators, 182–183, 235–236, 257

primitives, 183–185, 190

reference variables, 190–191, 202–203, 376–378

asterisks (*)

compound assignment operators, 236

import statements, 14, 16

multiplication, 244

precedence, 257

autoboxing with ArrayLists, 384–388

automatic local variables, 55–57

automatic variables. See local variables

       B

backslashes () for escaped characters, 182

base 2 (binary) integers, 178

base 8 (octal) integers, 178–179

base 10 (decimal) integers, 178

base 16 (hexadecimal) literals, 178, 180

basic for loops, 288

conditional expressions, 289–290

declaration and initialization, 288–289

iteration expressions, 289–290

loop issues, 290–292

behaviors, description, 2

between() method, 361

binary (base 2) integers, 178

binary literals, 179

bitwise operators, 251–252

blocks

initialization, 145–147

variables, 193

boolean type and values

bit depth, 53

default values, 196

do loops, 287

in for loops, 288–289

if statements, 276–277

invert operator, 255–256

literals, 181

relational operators, 236

while loops, 286

braces ({}). See curly braces ({})

branching

if-else, 273–277

switch statements. See switch statements

break statement

in for loops, 290

key points, 326

loop constructs, 294–296

switch statements, 278, 281–283

bugs. See exceptions

bytes

case constants, 278–279

default values, 196

and int, 184

ranges, 53

       C

calendar data

classes, 357–358

factory classes, 359

formatting, 362

immutability, 358–359

key points, 398–399

using and manipulating, 360–361

call stack exceptions, 303–305

CamelCase, 9

capacity of strings, 354

carets (^)

bitwise operators, 251–252

exclusive-OR operators, 255

case sensitivity

identifiers, 7

string comparisons, 348–349

case statements, 278–280

casts, 184

assignment, 235

explicit, 185–186

implicit, 186

key points, 159, 220

overview, 118–121

precision, 188–189

primitives, 185–188

catch clause, 299–300

chained methods, 356

chaining constructors, 134

characters and char type

bit depth, 53

case constants, 278–279

comparisons, 237

default values, 196

literals, 181–182

charAt() method, 348–349

checked exceptions

handling, 314–315

interface implementation, 123

overloaded methods, 111

overridden methods, 108, 110

ChronoUnit enum, 361

.class files, 12

ClassCastException class

description, 322

downcasts, 119

classes

access, 17–21

compiling, 11

constructors. See constructors

declaring, 17–18

defining, 9–10

description, 2

extending, 18, 102

final, 20–21, 59–61

import statements, 13–14

interface implementation, 123

launching applications with java, 11–12

main() method, 12–13

member declarations, 28

names, 8–9, 151

overriding, 3

source file declaration rules, 10

wrapper, 320

cleaning up garbage collection, 218

clear() method, 383

code conventions, 7–9

collections, 58

colons (:)

conditional operators, 250–251

labels, 296

commas (,)

in for loops, 288–289

variables, 185

comments in source code files, 10

comparisons

instanceof, 242–244

relational operators, 236–241

strings, 348–349

compiler and compiling

casts, 119

interface implementation, 122–123

javac, 11

overloaded methods, 114

compiler errors

assignments, 188–189

instanceof, 244

compound assignments

with casts, 189

operators, 236

strings, 247

concat() method, 348–349

concatenating strings, 246–248, 261, 348–349

concrete classes

abstract methods implemented by, 106

creating, 23

subclasses, 46–47

concrete methods, 102

conditional operators

key points, 261

overview, 250–251

conditions

do loops, 287

in for loops, 288–290

if-else branching, 273–277

switch statements. See switch statements

while loops, 286

constant specific class body, 65–66

constants

case, 278–279

enum, 62

interface, 26–27

names, 9

String class, 347

constructing arrays, 364–367, 370–372

constructors, 132

basics, 133

calendar data, 359

chaining, 134

declarations, 50–51

default, 135–137

enums, 65–66

inheritance, 93, 140

key points, 75, 160–161

overloaded, 140–145

rules, 135–136

strings, 341

super() and this() calls, 144

contains() method, 383

continue statement

key points, 326

loop constructs, 294–295

controls, 17

conventions

code, 7–9

identifiers, 6

names, 2

conversions

return type, 131

types. See casts

cost reduction, object-oriented design for, 100

counting

instances, 148

references, 212

covariant returns, 129–130

cross-platform execution, 5

curly braces ({})

abstract methods, 46

arrays, 370, 372, 374

class members, 196, 199

if expressions, 273, 275

instance variables, 196

lambdas, 395

methods, 46

optional, 273

       D

D suffix, 181

dashes (-)

compound assignment operators, 236

decrement operators, 248–249

precedence, 257

subtraction, 244

date data

using and manipulating, 360–361

formatting, 362

DateTimeFormatter class, 358, 361–362

Deadly Diamond of Death, 102

decimal (base 10) integers, 178

decimal literals with underscores, 179

declarations

arrays, 57–59, 363–364, 370–372

basic for loops, 288–289

class members, 28

classes, 17–18

constructors, 50–51

enhanced for loops, 293

enum elements, 65–67

enums, 62–64

exceptions, 312–317

interface constants, 26–27

interfaces, 23–26

polymorphic, 381

reference variables, 53–54

return types, 129–132

source file rules, 10

variables, 51–61, 75–76

decrement operators

key points, 261

working with, 248–250

default access

description, 17

overview, 18–19

and protected, 30, 36–42

default case in switch statements, 283–284

Default protection, 30

defaults

constructors, 135–137

interface methods, 28

primitive and object type instance variables, 195–198

defining

classes, 9–10

exceptions, 306–307

delete() method, 354–355

deleting strings, 354–355

diamond syntax, 388–389

distributed computing, 5

division

compound assignment, 236

operator, 244

precedence, 257

do loops, 287

dots (.)

access, 31–32

class names, 151

instance references, 151

variable argument lists, 50

double type

casts, 186

default values, 196

floating-point literals, 180

ranges, 53

underscores, 179

downcasts, 119

ducking exceptions, 303, 312

duplicates in ArrayLists, 383

       E

elements in arrays. See arrays

ellipses (...) in variable argument lists, 50

else statements, 273–277

encapsulation

benefits, 100

description, 4

key points, 157

overview, 88–91

reference variables, 389–390, 401

entry points in switch statements, 281

enums, 62

case constants, 278–279

constants, 62

declaring, 62–64

declaring elements, 65–67

equality tests, 241

key points, 76–77

EOFException class, 311, 314

equal signs (=)

assignment, 182, 235

boxing, 386–387

compound assignment operators, 236

equality tests, 237–241

relational operators, 236–237

equality and equality operators

enums, 241

objects, 386–387

precedence, 257

primitives, 238

references, 238–240

strings, 240–241, 281

equals() method, 240–241, 386–387

equalsIgnoreCase() method, 348–349

Error class, 307

Exception class, 306–307

ExceptionInInitializerError class

description, 322

init blocks, 147

exceptions, 298–299

creating, 317–318

declarations, 312–317

defining, 306–307

hierarchy, 307–309

interface implementation, 123

JVM thrown, 319–320

key points, 327

list of, 321–322

matching, 309–310

overridden methods, 108, 110

programmatically thrown, 320–321

propagating, 303–306

rethrowing, 317

sources, 319

try and catch, 299–303

exclamation points (!)

boolean invert operator, 255–256

precedence, 257

relational operators, 236–237

exclusive-OR (XOR) operator, 255

execution entry points in switch statements, 281

exit() method

loops, 290

try and catch, 324

explicit casts, 185–186

explicit values in constructors, 134

expressions

enhanced for loops, 293

if statements, 276–277

extended ASCII set, 53

extending

classes, 18, 102

inheritance in, 94

interfaces, 124

extends keyword

illegal uses, 127

IS-A relationships, 97

       F

F suffix, 181

factory classes, 359

fall-through in switch statements, 281–283

false value, 181

features and benefits, 3–5

FileNotFoundException class, 311–312

final arguments, 44–45

final classes, 20–21, 59–61

final constants, 26–27

final methods

nonaccess member modifiers, 43–45

overriding, 108

final modifiers

increment and decrement operators, 250

variables, 42, 59

finalize() method, 218–219

finally clauses, 301–303

flexibility from object orientation, 88

float type and floating-point numbers

assigning, 188

casts, 187

classes, 20

comparisons, 237

default values, 196

literals, 180–181

ranges, 53

underscores, 179

flow control, 272

break and continue statements, 294–295

do loops, 287

for loops, 287–293

if-else branching, 273–277

labeled statements, 295–297

switch statements. See switch statements

unlabeled statements, 295

while loops, 285–286

for loops

basic, 288–292

enhanced, 292–293

forced exits from loops, 290

forcing garbage collection, 215–218

format() method, 362

formatting calendar data, 362

fractions, 180

fully qualified names, 13

       G

garbage collection

cleaning up before, 218

forcing, 215–218

key points, 222

objects eligible for, 213–215

overview, 210

garbage collector

operation, 212

overview, 210

running, 210

gc() method, 215–216

generics, 381

get() method, 383

getRuntime() method, 216

getters encapsulation, 89

greater than signs (>)

precedence, 257

relational operators, 236–237

guarded regions, 299

       H

HAS-A relationships

key points, 157

overview, 96–100

heap

garbage collection, 210

key points, 220

overview, 176–177

hexadecimal (base 16) literals, 178, 180

hiding implementation details, 89

hierarchy of exceptions, 307–309

       I

IDE (integrated development environment), 11

identifiers, 2

key points, 70

legal, 6–7

if-else branching

key points, 325–326

overview, 273–277

IllegalArgumentException class

description, 322

programmatically thrown exceptions, 321

IllegalStateException class, 322

immutability

calendar data, 358–359

strings, 340–347

implementation details, hiding, 89

implementing interfaces

key points, 159

overview, 122–128

implements keyword

illegal uses, 127

IS-A relationships, 97

implicit casts

assignment, 235

primitives, 186

import statements

key points, 70

overview, 13–14

source code files, 10

static, 14–16

increment operators

key points, 261

working with, 248–250

indexes

ArrayLists, 380

arrays, 12, 368

out-of-range, 369

string, 348–349

zero-based, 12

indexOf() method, ArrayLists, 383

IndexOutOfBoundsException class, 308

indirect interface implementation, 243

inheritance

access modifiers, 31–33, 38–39

constructors, 140

evolution, 93–95

HAS-A relationships, 98–100

IS-A relationships, 96–97

key points, 157

multiple, 102, 126–128

overview, 3, 92–93

inherited methods, overriding, 109

initialization

arrays, 202, 368–374

basic for loops, 288–289

loop elements, 370

object references, 201–202

primitives, 199–201

variables, 56, 185

initialization blocks, 145–147

inheritance, 93

key points, 161

inner classes, 17

insert() method, 354–355

inserting string elements, 355

instance methods

inheritance, 93

overriding, 108

polymorphic, 104

instance variables, 54–55

constructors, 134

default values, 195–198

description, 2, 193

on heap, 176–177

inheritance, 93

instanceof operator

key points, 260

object tests, 242–243

instances

counting, 148

initialization blocks, 146

references to, 151

instantiation, 160–161

Integer class, 15–16, 321

integers and int data type

and byte, 184

case constants, 278–279

casts, 186–187

comparisons, 237

default values, 196

literals, 178

ranges, 53

remainder operator, 246

integrated development environment (IDE), 11

interfaces, 2, 89

vs. abstract classes, 25

constants, 26–27

constructors, 136

declaring, 23–26

extending, 124

implementing, 122–128, 159

indirect implementation, 243

key points, 72–73

methods, 28–29

names, 8–9

overview, 3

invert operator, 255–256

invoking

overloaded methods, 112–115

polymorphic methods, 103

IOException class

checked exceptions, 314

files, 311–312

IS-A relationships

key points, 157

overview, 96–97

polymorphism, 101

return types, 132

ISO Latin-1 characters, 53

isolation of references, 214–215

iteration in basic for loops, 289–290

       J

java command, 11–12

java.io.IOException class

checked exceptions, 314

files, 311–312

java.lang.ClassCastException class

description, 322

downcasts, 119

java.lang.Exception class, 306–307

java.lang.Integer class, 15–16, 321

java.lang.Object class, 92

java.lang.Object.equals() method, 240–241

java.lang.Runtime class, 216

java.lang.RuntimeException class, 308, 312–314

java.lang.StringBuilder class, 340

key points, 398

methods, 354–356

overview, 352

vs. StringBuffer, 352–353

java.time.DateTimeFormatter class, 358, 361–362

java.time.LocalDate class, 357, 362

java.time.LocalDateTime class, 357, 362

java.time.LocalTime class, 357, 362

java.time.Period class, 358, 361

java.time.temporal package, 361

java.time.temporal.TemporalAmount interface, 358

java.util.ArrayList class. See ArrayList class

java.util.function.Predicate interface, 393–395

java.util.List interface, 381

Java Virtual Machine (JVM), 5, 11

javac, compiling with, 11

       K

keywords, 2, 7

       L

L suffix, 180

labeled statements, 295–297

lambdas, 390–396, 401

launching applications, 11–12

leaks, memory, 4

legal identifiers, 6–7

length() method, 350

length of arrays and strings, 350

less than signs (<)

precedence, 257

relational operators, 236–237

libraries, 4

lists and List interface, 381

ArrayLists. See ArrayList class

implementations, 381

literals

binary, 179

boolean, 181

character, 181–182

floating-point, 180–181

hexadecimal, 180

integer, 178

key points, 220

octal, 179

primitive assignments, 183–184

strings, 182, 347

local arrays, 202

local object references, 201–202

local primitives, 199–201

local variables, 198–199

access modifiers, 42–43

description, 193

key points, 74

on stack, 55, 176–177

working with, 55–57

LocalDate class, 357, 362

LocalDateTime class, 357, 362

LocalTime class, 357, 362

logical operators, 251

bitwise, 251–252

key points, 261–262

non-short-circuit, 254–256

precedence, 257

short-circuit, 252–254, 276–277

long type

default values, 196

ranges, 53

loop constructs, 285

break and continue, 294–295

do, 287

element initialization, 370

for, 287–293

key points, 326

while, 285–286

lowercase characters in strings, 351

       M

main() method, 12–13

exceptions, 303–305

overloaded, 115

maintainability, object orientation for, 88

mark and sweep algorithm, 212

matching exceptions, 309–310

MAX_VALUE constant, 16

meaningfully equivalent objects, 240

member modifiers, nonaccess, 43–50

members

access. See access and access modifiers

declaring, 28

key points, 74–75

memory

garbage collection. See garbage collection

strings, 347

memory leaks, 210

memory management, 4

methods

abstract, 45–48

access modifiers. See access and access modifiers

ArrayLists, 382–384

chained, 356

description, 2

enums, 65–66

factory, 359

final, 43–45, 59

instance, 104, 108

interface implementation, 122–123

interfaces, 28–29

names, 9

native, 49

overloaded, 111–117

overridden, 105–111

recursive, 320

stacks, 303–305

static, 61, 148–150

strictfp, 49

String, 348–352

StringBuilder, 354–356

synchronized, 48–49

variable argument lists, 49–50

minus signs (–)

compound assignment operators, 236

decrement operators, 248–249

precedence, 257

subtraction, 244

modifiers. See access and access modifiers

modulus operator

overview, 245–246

precedence, 257

multidimensional arrays

constructing, 366

declaring, 58–59, 364

reference assignments, 377–378

multiple inheritance, 102, 126–128

multiplication

compound assignment, 236

operator, 244

precedence, 257

multithreaded programming, 5

mutators in encapsulation, 89

       N

names

classes and interfaces, 8–9

constants, 9

constructors, 51, 133, 135

conventions, 2

dot operator, 151

fully qualified, 13

labels, 296

methods, 9

shadow variables, 208–209

variables, 9

narrowing conversions, 186

native methods, 49

negative numbers

from casts, 189

representing, 53

nested classes, 17

nested if-else statements, 273

new keyword

arrays, 364

calendar data, 359

no-arg constructors, 135–136

NoClassDefFoundError class, 322

nonaccess member modifiers, 19–20, 43

abstract methods, 45–48

final arguments, 44–45

final methods, 43–45

key points, 71–72

methods with variable argument lists, 49–50

native methods, 49

strictfp methods, 49

synchronized methods, 48–49

not equal operator (!=), 237

null values

reference variables, 183, 191

returning, 130

wrapper variables, 388

nulling references, 213

NullPointerException class, 314

arrays, 368

description, 322

reference variables, 319–320

wrapper variables, 388

NumberFormatException class

description, 322

string conversions, 321

numbers

primitives. See primitives

with string concatenation, 246–247

with underscores, 178–179

       O

Object class, 92

object orientation (OO), 87–88

benefits, 100

casting, 118–121

constructors. See constructors

description, 4

encapsulation, 88–91

inheritance, 92–100

initialization blocks, 145–147

interface implementation, 122–128

overloaded methods, 111–117

overridden methods, 105–111

polymorphism, 101–105

return types, 129–132

statics, 148–154

objects and object references

arrays, 58, 363–364, 374–375

default values, 196–198

description, 2, 183

equality, 386–387

garbage collection, 213–219

on heap, 176–177

initializing, 201–202

instanceof comparisons, 242–244

overloaded methods, 113–114

passing, 205–207

strings as, 341

octal (base 8) integers, 178–179

of() method, 361

one-dimensional arrays

constructing, 364–366

reference assignments, 376–377

operands, 234

operators, 233–234

arithmetic, 244–249

assignment, 235–236

conditional, 250–251

increment and decrement, 248–250

instanceof, 242–244

logical, 251–256

precedence, 256–258, 262

relational, 236–241

OR expressions, 253–255

order of instance initialization blocks, 146

out-of-range array indexes, 369

out-of-scope variables, 194

OutOfMemoryException class, 218

overloaded constructors, 140–145

overloaded methods, 111

invoking, 112–115

key points, 158

legal, 112, 116

main(), 13, 115

vs. overridden, 112, 117

polymorphism, 115

return types, 129

overridden methods, 105–109

illegal, 110–111

invoking superclass, 109–110

vs. overloaded, 112, 117

polymorphism, 115

return types, 129–130

static, 154

overriding

classes, 3

key points, 158

private methods, 36

       P

package-centric languages, 17

package-level access, 18–19

package statement in source code files, 10

packages

access, 17

classes in, 14

parameters

vs. arguments, 49–50

lambdas, 395

parentheses ()

arguments, 44, 50

conditional operator, 250

in for loops, 288

if expressions, 273, 276–277

operator precedence, 246–247, 258, 262

string concatenation, 247

parseInt() method, 321

passing

key points, 221

object reference variables, 205–207

pass-by-value, 206–207

primitive variables, 207–208

Peabody, Marc, 185

percent signs (%)

precedence, 257

remainder operator, 245–246

Period class, 358, 361

pipe (|) characters

bitwise operators, 251–252

logical OR operator, 253–255

plus signs (+)

addition, 244

compound assignment operators, 236

increment operators, 248–249

precedence, 257

string concatenation, 246–248

polymorphism

abstract classes, 22

declarations, 381

inheritance, 95

key points, 157

overloaded and overridden methods, 115

overview, 101–105

pools for String constants, 347

postfix increment operators, 248–249

precedence of operators, 245, 247, 256–258, 262

precision

casts, 186, 188–189

floating-point literals, 181

floating-point numbers, 188

Predicate interface, 393–395

prefix increment operators, 248–249

primitives

arrays, 58, 363–364, 374

assignments, 183–185, 190

casting, 185–188, 220

comparisons, 238

declarations, 51–53

default values, 195–196

final, 59

initializing, 199–201

literals, 178–182

passing, 207–208

returning, 131

wrapper classes, 192

printStackTrace() method, 308

private modifiers, 30

overriding, 36

overview, 34–36

programmatically thrown exceptions, 320–321

Project Coin, diamond syntax, 388–389

propagating uncaught exceptions, 303–306

protected modifiers, 30, 36–42

public access, 19

public interface for exceptions, 312–317

public modifiers, 30

constants, 26–27

encapsulation, 89

overview, 33–34

public static void main() method, 12–13

       Q

question marks (?) for conditional operators, 250–251

       R

ranges, numbers, 53

reachable objects, 210

reassigning reference variables, 213–214

recursive methods, 320

redefined static methods, 154

reference counting, 212

references, 101

arrays, 368

assigning, 190–191, 202–203

casting, 118–121, 159

declaring, 53–54

description, 183

encapsulation, 389–390, 401

equality, 238–240

instances, 151

isolating, 214–215

multidimensional arrays, 377–378

nulling, 213

one-dimensional arrays, 376–377

overloaded methods, 113–114

passing, 205–207

reassigning, 213–214

returning, 130

strings, 342–347

regions, guarded, 299

relational operators, 236–237

equality, 237–241

key points, 260

precedence, 257

remainder operator, 245–246

remove() method, 384

removing ArrayList elements, 384

replace() method, 350

replacing string elements, 350

rethrowing exceptions, 317

return statement

for loops, 290

lambdas, 395

return type

constructors, 51, 133, 135

declarations, 129–132

key points, 159

overloaded methods, 111, 129

overridden methods, 108, 129–130

returning values, 130–131

reuse

inheritance for, 94

names, 208–209

reverse() method, 355

reversing strings, 355

rules

constructors, 135–136

source file, 10

Runtime class, 216

runtime exceptions for overridden methods, 108

RuntimeException class, 308, 312–314

       S

sandbox, 5

scope

in for loops, 291

key points, 220

variables, 192–195

security, 5

semicolons (;)

abstract methods, 22, 45

enums, 64

in for loops, 288

labels, 296

lambdas, 395

native methods, 49

while loops, 287

serialization, 5

setters encapsulation, 89

shadowed variables, 56, 193, 208–209

short-circuit logical operators

if statements, 276–277

overview, 252–254

precedence, 257

short type

case constants, 278–279

default values, 196

ranges, 53

signatures of methods, 117, 123

signed numbers, 53

size

ArrayLists, 383–384

arrays, 59, 364, 366, 370, 372, 374

assignment issues, 235

numbers, 53

size() method, 383–384

slashes (/)

compound assignment operators, 236

division, 244

precedence, 257

source code file declaration rules, 10, 71

square brackets ([])

array elements, 58

arrays, 363

stack

exceptions, 320

key points, 220

local variables, 55

methods, 303–305

overview, 176–177

StackOverflowError class

description, 322

recursive methods, 320

states, 2

static constants, 26–27

static imports, 14–16

static initialization blocks, 146

static interface methods, 28–29

static variables and methods, 14–15, 61

constructors, 136

description, 193

inheritance, 93

key points, 76, 161

overriding, 109, 154

overview, 148–150

streams, 390

strictfp modifiers

classes, 19–20

methods, 49

String class, 340–347

constant pool, 347

key points, 398

methods, 348–352

object references, 203–204

StringBuffer class, 340, 352–353

StringBuilder class, 340

key points, 398

methods, 354–356

overview, 352

vs. StringBuffer, 352–353

StringIndexOutOfBoundsException class, 308–309

strings, 340

appending, 341–342, 353–354

case constants, 278–279

comparing, 348–349

concatenating, 246–248, 261, 348–349

creating, 348

deleting, 354–355

equality, 240–241, 281

immutability, 340–347

inserting elements into, 355

key points, 398

length, 350

literals, 182, 347

lower case, 351

memory, 347

methods, 348–352

replacing elements in, 350

reversing, 355

substrings, 350–351

trimming, 352

upper case, 351

strong typing, 5

subclasses

concrete, 46–47

inheritance, 3

substring() method, 350–351

subtraction

compound assignment, 236

operator, 244

precedence, 257

subtypes for reference variables, 101

super() calls for constructors, 144

super constructor arguments, 137

superclasses, 3

constructors, 135

overridden methods, 109–110

switch statements, 278

break and fall-through, 281–283

default case, 283–284

exercise, 285

key points, 325–326

legal expressions, 278–280

string equality, 281

synchronization methods, 48–49

System.exit() method

loops, 290

try and catch, 324

System.gc() method, 215–216

       T

TemporalAmount interface, 358

ternary operator

conditional, 250–251

key points, 261

test() method, 393, 396

this() calls for constructors, 135, 144

this keyword, 57

threads in garbage collector, 212

three-dimensional arrays, 59, 364

Throwable class, 307

thrown exceptions

description, 299

JVM, 319–320

programmatically, 320–321

time data

using and manipulating, 360–361

formatting, 362

toLowerCase() method, 351

toString() method

ArrayLists, 381

String, 351

StringBuilder, 356

toUpperCase() method, 351

transient variables, 60–61

trim() method, 352

true value, 181

truncating from casts, 189

try and catch feature

finally, 301–303

overview, 299–300

two-dimensional arrays, 59, 364

two’s complement notation and casts, 189

types

array declarations, 363

assignments, 235

casting. See casts

return. See return type

variables, 183

       U

u prefix, 181

UML (Unified Modeling Language), 100

unary operators, precedence, 257

unassigned variables

key points, 221

working with, 195–199

uncaught exceptions, 303–306

unchecked exceptions

description, 314–315

overridden methods, 108

underscores (_) in numeric literals, 178–179

Unicode characters

char type, 53

identifiers, 6

literals, 181

strings, 341

Unified Modeling Language (UML), 100

uninitialized variables

key points, 221

working with, 195–199

unlabeled statements, 295

until() method, 361

unwinding the stack, 308

upcasting, 120

upper case for strings, 351

       V

values() method, 66

values of variables, 182

var-args

key points, 75

methods, 49–50

variable argument lists, 49–50

variables

access. See access and access modifiers

assignments. See assignments

declarations, 51–53, 75–76

description, 2

enums, 65–66

final, 59

in for loops, 291

heap and stack, 176–177

initializing, 185

instance, 54–55

local. See local variables

names, 9

primitives, 51–53

scope, 192–195

shadow, 208–209

static, 61, 148–150

transient, 60–61

uninitialized and unassigned, 195–199, 221

values, 182

volatile, 61

vertical bars (|)

bitwise operators, 251–252

logical OR operator, 253–255

precedence, 257

visibility, access, 18, 43

void return type, 131

volatile variables, 61

       W

Walraven, Fritz, 258

while loops

labeled, 297

working with, 285–286

whitespace, trimming from strings, 352

widening conversions, 186

wildcards in import statements, 14, 16

wrapper classes

primitives, 192

strings, 320

wrappers, ArrayLists, 384–388

       X

XOR (exclusive-OR) operator, 255

       Z

zero-based indexes, 12

0x prefix, 179

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.204.166