Head First Java: A Learner's Guide to Real-World Programming. Covers Java 8-17. 3 Ed

Head First Java: A Learner's Guide to Real-World Programming. Covers Java 8-17. 3 Ed

Head First Java: A Learner's Guide to Real-World Programming. Covers Java 8-17. 3 Ed
Автор: Bates Bert, Gee Trisha, Sierra Kathy
Дата выхода: 2022
Издательство: O’Reilly Media, Inc.
Количество страниц: 1597
Размер файла: 32.8 MB
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

Other books in O’Reilly’s Head First series....12

Table of Contents (the real thing)....17

How to Use This Book: Intro....33

Who is this book for?....35

Who should probably back away from this book?....36

We know what you’re thinking....37

And we know what your brain is thinking....37

Metacognition: thinking about thinking....44

Here’s what WE did:....46

Here’s what YOU can do to bend your brain into submission....49

What you need for this book:....52

Last-minute things you need to know:....55

Technical Reviewers for the 3rd Edition....58

Other people to acknowledge for the 3rd Edition....59

Technical Editors for the 2nd Edition....62

Other people to credit, for the 2nd Edition....64

Just when you thought there wouldn’t be any more acknowledgments*....67

1. Breaking the Surface: Dive In: A Quick Dip....69

The way Java works....70

What you’ll do in Java....71

A very brief history of Java....72

Speed and memory usage....74

Code structure in Java....80

What goes in a source file?....81

What goes in a class?....82

What goes in a method?....82

Anatomy of a class....83

Writing a class with a main()....84

What can you say in the main method?....90

Looping and looping and.......94

Simple boolean tests....95

Example of a while loop....96

Conditional branching....98

Coding a serious business application....101

Monday morning at Bob’s Java-enabled house....103

Phrase-O-Matic....108

How it works....109

Exercise....110

Code Magnets....110

BE the Compiler....113

JavaCross....114

Mixed Messages....116

Pool Puzzle....119

Exercise Solutions....121

Sharpen your pencil....121

Code Magnets....122

BE the Compiler....122

Pool Puzzle....124

JavaCross....125

Mixed Messages....126

2. A Trip to Objectville: Classes and Objects....128

Chair Wars....129

(or How Objects Can Change Your Life)....129

At Laura’s desk....130

At Brad’s laptop at the cafe....131

Back at Laura’s desk....132

At Brad’s laptop at the beach....133

Back at Laura’s desk....135

At Brad’s laptop on his lawn chair at the Telluride Bluegrass Festival....135

So, Brad the OO guy got the chair and desk, right?....136

What about the Amoeba rotate()?....139

The suspense is killing me. Who got the chair and desk?....141

When you design a class, think about the objects that will be created from that class type. Think about:....144

What’s the difference between a class and an object?....147

A class is not an object (but it’s used to construct them)....147

Making your first object....148

Making and testing Movie objects....151

Quick! Get out of main!....155

The two uses of main:....155

The Guessing Game....156

Running the Guessing Game....159

Exercise....164

BE the Compiler....165

Code Magnets....166

Pool Puzzle....169

Who Am I?....172

Exercise Solutions....173

Code Magnets....174

BE the Compiler....174

Puzzle Solutions....176

Who Am I?....177

3. Know Your Variables: Primitives and References....179

Declaring a variable....180

“I’d like a double mocha, no, make it an int.”....183

Primitive Types....185

You really don’t want to spill that.......186

Back away from that keyword!....190

This table reserved....192

Controlling your Dog object....193

An object reference is just another variable value....196

Java Exposed....200

Life on the garbage-collectible heap....202

Life and death on the heap....205

An array is like a tray of cups....207

Arrays are objects too....210

Make an array of Dogs....210

Control your Dog (with a reference variable)....213

What happens if the Dog is in a Dog array?....215

A Dog example....216

Exercise....219

BE the Compiler....219

Code Magnets....221

Pool Puzzle....223

A Heap o’ Trouble....226

The case of the pilfered references....228

Five-Minute Mystery....229

Exercise Solutions....230

Sharpen your pencil....230

Code Magnets....231

BE the Compiler....232

Puzzle Solutions....234

Five-Minute Mystery....235

A Heap o’ Trouble....236

4. How Objects Behave: Methods Use Instance Variables....238

Remember: a class describes what an object knows and what an object does....239

Can every object of that type have different method behavior?....239

The size affects the bark....241

You can send things to a method....244

You can get things back from a method....245

You can send more than one thing to a method....247

Calling a two-parameter method and sending it two arguments....247

You can pass variables into a method, as long as the variable type matches the parameter type....248

Java is pass-by-value. That means pass-by-copy.....249

Reminder: Java cares about type!....252

Cool things you can do with parameters and return types....253

Encapsulation....256

Do it or risk humiliation and ridicule.....256

Hide the data....258

Java Exposed....259

Encapsulating the GoodDog class....261

How do objects in an array behave?....263

Declaring and initializing instance variables....265

The difference between instance and local variables....267

Comparing variables (primitives or references)....269

Exercise....276

BE the Compiler....276

Who Am I?....278

Mixed Messages....279

Pool Puzzle....281

Five-Minute Mystery....284

Exercise Solutions....286

Sharpen your pencil....286

BE the Compiler....286

Who Am I?....287

Puzzle Solutions....288

Five-Minute Mystery....289

Mixed Messages....289

5. Extra-Strength Methods: Writing A Program....291

Let’s build a Battleship-style game: “Sink a Startup”....292

First, a high-level design....295

The “Simple Startup Game” a gentler introduction....297

Developing a Class....300

The three things we’ll write for each class:....302

Writing the method implementations....306

Writing test code for the SimpleStartup class....308

Based on this prep code:....308

Here’s what we should test:....308

Test code for the SimpleStartup class....309

The checkYourself() method....311

Just the new stuff....312

Final code for SimpleStartup and SimpleStartupTestDrive....315

Prep code for the SimpleStartupGame class Everything happens in main()....319

The game’s main() method....323

random() and getUserInput()....325

One last class: GameHelper....326

Let’s play....328

What’s this? A bug ?....329

Gasp!....329

More about for loops....331

Regular (non-enhanced) for loops....332

Trips through a loop....334

Difference between for and while....335

The enhanced for loop....338

Casting primitives....339

Exercise....341

BE the JVM....341

Code Magnets....343

JavaCross....346

Mixed Messages....349

Exercise Solutions....351

Be the JVM....351

Code Magnets....352

Puzzle Solutions....353

JavaCross....353

Mixed Messages....354

6. Using the Java Library: Get to Know the Java API....356

In our last chapter, we left you with the cliff-hanger: a bug....357

How it’s supposed to look....357

How the bug looks....358

So what happened?....359

How do we fix it?....361

Option one is too clunky....362

Option two is a little better, but still pretty clunky....363

Wake up and smell the library....367

Some things you can do with ArrayList....369

Java Exposed....374

Solution....376

Sharpen your pencil....376

Comparing ArrayList to a regular array....379

Let’s fix the Startup code....381

New and improved Startup class....383

Let’s build the REAL game: “Sink a Startup”....385

What needs to change?....388

Who does what in the StartupBust game (and when)....389

Prep code for the real StartupBust class....393

The final version of the Startup class....405

Super powerful Boolean expressions....407

Ready-Bake Code....409

Using the Library (the Java API)....413

You have to know the full name* of the class you want to use in your code.....414

How to discover the API....422

Browse a book....424

Use the HTML API docs....426

Using the class documentation....430

Exercise....432

Code Magnets....433

JavaCross....435

Exercise Solutions....437

Code Magnets....438

JavaCross....439

7. Better Living in Objectville: Inheritance and Polymorphism....442

Chair Wars Revisited.......444

What about the Amoeba rotate()?....446

Understanding Inheritance....448

An inheritance example:....450

Let’s design the inheritance tree for an Animal simulation program....454

Using inheritance to avoid duplicating code in subclasses....455

Do all animals eat the same way?....457

Which methods should we override?....458

Looking for more inheritance opportunities....459

Which method is called?....464

Designing an Inheritance Tree....466

Using IS-A and HAS-A....468

But wait! There’s more!....471

How do you know if you’ve got your inheritance right?....473

When designing with inheritance, are you using or abusing?....478

So what does all this inheritance really buy you?....479

Inheritance lets you guarantee that all classes grouped under a certain supertype have all the methods that the supertype has*....481

Keeping the contract: rules for overriding....493

Overloading a method....496

Exercise....498

Mixed Messages....498

BE the Compiler....500

Exercise Solutions....506

BE the Compiler....507

Mixed Messages....508

Pool Puzzle....508

8. Serious Polymorphism: Interfaces and Abstract Classes....510

Did we forget about something when we designed this?....511

The compiler won’t let you instantiate an abstract class....517

Abstract vs. Concrete....519

Abstract methods....524

You MUST implement all abstract methods....526

Polymorphism in action....531

Uh-oh, now we need to keep Cats, too....532

What about non-Animals? Why not make a class generic enough to take anything?....535

So what’s in this ultra-super-megaclass Object?....538

Using polymorphic references of type Object has a price.......542

When a Dog won’t act like a Dog....545

Objects don’t bark....547

Get in touch with your inner Object....552

Polymorphism means “many forms.”....554

Casting an object reference back to its real type.....558

What if you need to change the contract?....564

Let’s explore some design options for reusing some of our existing classes in a PetShop program....565

Interface to the rescue!....578

Making and implementing the Pet interface....579

Invoking the superclass version of a method....586

Exercise....592

Pool Puzzle....597

Exercise Solutions....599

What’s the Picture ?....599

What’s the Declaration?....601

Pool Puzzle....602

9. Life and Death of an Object: Constructors and Garbage Collection....604

The Stack and the Heap: where things live....606

Methods are stacked....609

A stack scenario....611

What about local variables that are objects?....612

If local variables live on the stack, where do instance variables live?....615

The miracle of object creation....617

Construct a Duck....620

Initializing the state of a new Duck....623

Using the constructor to initialize important Duck state*....627

Make it easy to make a Duck....630

Be sure you have a no-arg constructor....630

Doesn’t the compiler always make a no-arg constructor for you? No!....632

Nanoreview: four things to remember about constructors....642

Wait a minute...we never DID talk about superclasses and inheritance and how that all fits in with constructors....644

The role of superclass constructors in an object’s life....648

Making a Hippo means making the Animal and Object parts too.......650

How do you invoke a superclass constructor?....654

Can the child exist before the parents?....657

Superclass constructors with arguments....660

Invoking one overloaded constructor from another....665

Now we know how an object is born, but how long does an object live?....673

What about reference variables?....679

Exercise....695

BE the Garbage Collector....695

Popular Objects....697

Five-Minute Mystery....699

Exercise Solutions....701

Be the Garbage Collector....701

Popular Objects....702

Five-Minute Mystery....704

10. Numbers Matter: Numbers and Statics....706

MATH methods: as close as you’ll ever get to a global method....708

The difference between regular (non-static) and static methods....710

What it means to have a class with static methods....712

Static methods can’t use non-static (instance) variables!....713

Static methods can’t use non-static methods, either!....716

Static variable: value is the same for ALL instances of the class....720

Initializing a static variable....724

static final variables are constants....727

final isn’t just for static variables.......730

Math methods....739

Wrapping a primitive....742

Java will Autobox primitives for you....747

Autoboxing works almost everywhere....748

But wait! There’s more! Wrappers have static utility methods too!....752

And now in reverse...turning a primitive number into a String....754

Number formatting....759

Formatting deconstructed.......760

The percent (%) says, “insert argument here” (and format it using these instructions)....762

The format String uses its own little language syntax....766

The format specifier....766

The only required specifier is for TYPE....768

What happens if I have more than one argument?....770

Just one more thing...static imports....772

Fireside Chats....775

Exercise....778

BE the compiler....779

True or False....781

Exercise Solution....782

Sharpen your pencil....782

BE the compiler....783

True or False....783

11. Data Structures: Collections and Generics....785

Tracking song popularity on your jukebox....787

Your first job, sort the songs in alphabetical order....789

Great question! You spotted the diamond operator....794

Exploring the java.util API, List and Collections....796

In the “Real-World”™ there are lots of ways to sort....797

“Natural Ordering,” what Java means by alphabetical....797

But now you need Song objects, not just simple Strings....800

Changing the Jukebox code to use Songs instead of Strings....802

It won’t compile!....803

The sort() method declaration....806

Generics means more type-safety....806

Learning generics....808

Using generic CLASSES....810

Using type parameters with ArrayList....812

Using generic METHODS....813

Here’s where it gets weird.......815

Revisiting the sort() method....819

In generics, “extends” means “extends or implements”....822

Finally we know what’s wrong.......823

The Song class needs to implement Comparable....823

The new, improved, comparable Song class....825

We can sort the list, but.......828

Using a custom Comparator....832

Updating the Jukebox to use a Comparator....834

Fill-in-the-blanks....836

But wait! We’re sorting in two different ways!....837

Sorting using only Comparators....839

Just the code that matters....842

What do we REALLY need in order to sort?....843

Enter lambdas! Leveraging what the compiler can infer....847

Where did all that code go?....849

Some interfaces have only ONE method to implement....850

Updating the Jukebox code with lambdas....851

Reverse Engineer....853

Uh-oh. The sorting all works, but now we have duplicates.......855

We need a Set instead of a List....857

The Collection API (part of it)....859

Using a HashSet instead of ArrayList....863

What makes two objects equal?....864

How a HashSet checks for duplicates: hashCode() and equals()....867

The Song class with overridden hashCode() and equals()....870

If we want the set to stay sorted, we’ve got TreeSet....874

What you MUST know about TreeSet.......876

TreeSet elements MUST be comparable....878

We’ve seen Lists and Sets, now we’ll use a Map....879

Creating and filling collections....881

Convenience Factory Methods for Collections....882

Finally, back to generics....884

Using polymorphic arguments and generics....885

But will it work with List?....886

What could happen if it were allowed...?....888

We can do this with wildcards....889

Using the method’s generic type parameter....891

Exercise....892

BE the Compiler, advanced....893

Exercise Solution....894

Fill-in-the-blanks....894

“Reverse Engineer” lambdas exercise....895

Sorting with lambdas....897

TreeSet exercise....897

BE the Compiler solution....898

12. Lambdas and Streams: What, Not How: Lambdas and Streams....901

Tell the computer WHAT you want....902

Fireside Chats....903

When for loops go wrong....905

Mixed Messages....905

Small errors in common code can be hard to spot....907

Building blocks of common operations....909

Introducing the Streams API....910

Getting started with Streams....912

Streams are like recipes: nothing’s going to happen until someone actually cooks them....914

Getting a result from a Stream....916

Stream operations are building blocks....918

Building blocks can be stacked and combined....920

Customizing the building blocks....921

Create complex pipelines block by block....922

Yes, because Streams are lazy....923

Terminal operations do all the work....924

Collecting to a List....925

Guidelines for working with streams....925

Correct! Stream operations don’t change the original collection.....928

Exercise....929

Code Magnets....929

Hello Lambda, my (not so) old friend....935

Passing behavior around....936

The shape of lambda expressions....939

Anatomy of a lambda expression....940

Variety is the spice of life....942

A lambda might have more than one line....942

Single-line lambdas don’t need ceremony....943

A lambda might not return anything....943

A lambda might have zero, one, or many parameters....944

How can I tell if a method takes a lambda?....945

Exercise....947

BE the Compiler, advanced....947

Spotting Functional Interfaces....949

Functional interfaces in the wild....950

Lou’s back!....953

Exercise....954

Ready-Bake Code....954

Lou’s Challenge #1: Find all the “rock” songs....956

Filter a stream to keep certain elements....958

Let’s Rock!....959

Getting clever with filters....961

Lou’s Challenge #2: List all the genres....963

Mapping from one type to another....964

Removing duplicates....966

Only one of every genre....967

Just keep building!....968

Sometimes you don’t even need a lambda expression....969

Collecting results in different ways....971

But wait, there’s more!....973

Checking if something exists....973

Find a specific thing....973

Count the items....974

Well, some operations may return something, or may not return anything at all....975

Optional is a wrapper....977

Yes, but now we have a way to ask if we have a result....978

Don’t forget to talk to the Optional wrapper....979

The Unexpected Coffee....981

Five-Minute Mystery....981

Pool Puzzle....982

Mixed Messages....985

Who Does What?....985

Exercise Solutions....986

Code Magnets....986

BE the Compiler....987

Sharpen your pencil....989

Five-Minute Mystery....990

Pool Puzzle....990

13. Risky Behavior: Exception Handling....992

Let’s make a Music Machine....993

The finished BeatBox looks something like this:....993

We’ll start with the basics....995

The JavaSound API....995

First we need a Sequencer....998

Something’s wrong!....998

What happens when a method you want to call (probably in a class you didn’t write) is risky?....999

Methods in Java use exceptions to tell the calling code, “Something Bad Happened. I failed.”....1002

The compiler needs to know that YOU know you’re calling a risky method....1004

An exception is an object... of type Exception....1007

If it’s your code that catches the exception, then whose code throws it?....1008

Flow control in try/catch blocks....1015

Finally: for the things you want to do no matter what....1016

Flow Control....1019

Did we mention that a method can throw more than one exception?....1020

Catching multiple exceptions....1020

Exceptions are polymorphic....1021

Multiple catch blocks must be ordered from smallest to biggest....1026

You can’t put bigger baskets above smaller baskets....1028

When you don’t want to handle an exception.......1033

Ducking (by declaring) only delays the inevitable....1036

Getting back to our music code.......1039

Exception Rules....1040

Code Kitchen....1041

Making actual sound....1043

Version 1: Your very first sound player app....1046

Making a MidiEvent (song data)....1049

MIDI message: the heart of a MidiEvent....1050

Anatomy of a message....1051

Change a message....1053

Version 2: Using command-line args to experiment with sounds....1055

Where we’re headed with the rest of the CodeKitchens....1057

Exercise....1059

True or False....1060

Code Magnets....1061

JavaCross....1063

Sharpen your pencil....1066

Exercise Solution....1066

True or False....1067

Code Magnets....1068

JavaCross....1069

14. A Very Graphic Story: Getting Gui....1071

It all starts with a window....1072

Put widgets in the window....1074

Your first GUI: a button on a frame....1075

But nothing happens when I click it.......1077

Getting a user event....1079

Listeners, Sources, and Events....1087

Getting back to graphics.......1091

Make your own drawing widget....1093

Fun things to do in paintComponent()....1095

Behind every good Graphics reference is a Graphics2D object....1097

Because life’s too short to paint the circle a solid color when there’s a gradient blend waiting for you....1100

We can get an event. We can paint graphics. But can we paint graphics when we get an event?....1106

GUI layouts: putting more than one widget on a frame....1108

Let’s try it with TWO buttons....1112

So now we need FOUR widgets....1112

And we need to get TWO events....1113

How do you get action events for two different buttons when each button needs to do something different?....1113

Inner class to the rescue!....1119

An inner class instance must be tied to an outer class instance*....1120

How to make an instance of an inner class....1122

Java Exposed....1126

Lambdas to the rescue! (again)....1132

ActionListener is a Functional Interface....1134

Lambdas, clearer and more concise....1135

Using an inner class for animation....1136

Code Kitchen....1141

Listening for a non-GUI event....1142

An easier way to make messages/events....1144

Version One: using the new static makeEvent() method....1146

Version Two: registering and getting ControllerEvents....1148

Version Three: drawing graphics in time with the music....1150

Exercise....1154

Who Am I?....1154

BE the Compiler....1155

Pool Puzzle....1157

Exercise Solutions....1159

Who am I?....1160

BE the Compiler....1160

Pool Puzzle....1162

15. Work on Your Swing: Using Swing....1164

Swing components....1165

Components can be nested....1165

Layout Managers....1167

How does the layout manager decide?....1169

Different layout managers have different policies....1171

The Big Three layout managers: border, flow, and box....1171

Playing with Swing components....1192

Code Kitchen....1201

Making the BeatBox....1203

Exercise....1210

Which code goes with which layout?....1211

Code Fragments....1213

GUI-Cross....1214

Exercise Solutions....1217

Which code goes with which layout?....1217

GUI-Cross....1219

16. Saving Objects (and Text): Serialization and File I/O....1221

Capture the beat....1222

Saving state....1224

Writing a serialized object to a file....1227

Data moves in streams from one place to another....1229

What really happens to an object when it’s serialized?....1230

But what exactly IS an object’s state? What needs to be saved?....1232

If you want your class to be serializable, implement Serializable....1236

Deserialization: restoring an object....1244

What happens during deserialization?....1246

Saving and restoring the game characters....1249

The GameCharacter class....1251

Version ID: A big serialization gotcha....1252

Using the serialVersionUID....1255

Object Serialization....1257

Writing a String to a Text File....1259

Text file example: e-Flashcards....1261

Quiz Card Builder (code outline)....1264

The java.io.File class....1270

Reading from a text file....1274

Quiz Card Player (code outline)....1277

Parsing with String split()....1282

NIO.2 and the java.nio.file package....1286

Path, Paths, and Files (messing with directories)....1287

Finally, a closer look at finally....1289

Remember, finally ALWAYS runs!!....1290

Finally, a closer look at finally, cont.....1291

There IS a better way!....1293

The try-with-resources (TWR), statement....1293

Autocloseable, the very small catch....1295

Autocloseable, it’s everywhere you do I/O....1296

Code Kitchen....1297

Saving a BeatBox pattern....1297

Restoring a BeatBox pattern....1299

Can they be saved?....1301

Exercise....1303

True or False....1303

Code Magnets....1304

Exercise Solutions....1307

True or False....1307

Code Magnets....1308

17. Make a Connection: Networking and Threads....1311

Real-time BeatBox chat....1312

Connecting, sending, and receiving....1317

1. Connect....1318

2. Receive....1325

Reading from the network with BufferedReader....1326

3. Send....1328

Writing to the network with PrintWriter....1328

There’s more than one way to make a connection....1330

Using a Socket....1330

The DailyAdviceClient....1333

DailyAdviceClient code....1335

Writing a simple server application....1338

DailyAdviceServer code....1340

Writing a Chat Client....1346

The really, really simple Chat Server....1349

Java has multiple threads but only one Thread class....1355

What does it mean to have more than one call stack?....1357

To create a new call stack you need a job to run....1359

To make a job for your thread, implement the Runnable interface....1360

How NOT to run the Runnable....1361

How we used to launch a new thread....1362

A better alternative: don’t manage the Threads at all....1364

Running one job....1364

The three states of a new thread....1365

The thread scheduler....1368

How did we end up with different results?....1372

Putting a thread to sleep....1376

Using sleep to make our program more predictable....1378

There are downsides to forcing the thread to sleep....1381

Counting down until ready....1382

Making and starting two threads (or more!)....1385

Pooling Threads....1386

Running multiple threads....1388

What will happen?....1389

Closing time at the thread pool....1390

Um, yes. There IS a dark side. Multithreading can lead to concurrency “issues.”....1393

Exercise....1396

Who Am I?....1396

New and improved SimpleChatClient....1398

Exercise....1403

Code Magnets....1403

Exercise Solutions....1406

Who Am I?....1406

Code Magnets....1406

Code Kitchen....1407

18. Dealing with Concurrency Issues: Race Conditions and Immutable Data....1410

What could possibly go wrong?....1411

The Ryan and Monica problem, in code....1414

The Ryan and Monica example....1417

We need to check the balance and spend the money as one atomic thing....1421

Using an object’s lock....1424

Using synchronized methods....1426

It’s important to lock the correct object....1427

The dreaded “Lost Update” problem....1429

Let’s run this code.......1431

Make the increment() method atomic. Synchronize it!....1433

Deadlock, a deadly side of synchronization....1437

You don’t always have to use synchronized....1439

Atomic variables....1439

Compare-and-swap with atomic variables....1441

Ryan and Monica, going atomic....1442

Writing a class for immutable data....1446

Using immutable objects....1447

Changing immutable data....1448

More problems with shared data....1452

Reading from a changing data structure causes an Exception....1454

Use a thread-safe data structure....1455

CopyOnWriteArrayList....1456

Exercise....1462

BE the JVM....1462

Five-Minute Mystery....1464

Exercise Solution....1466

BE the JVM....1466

Five-Minute Mystery....1467

A. Final Code Kitchen....1469

Final BeatBox client program....1471

Final BeatBox server program....1482

B. The top ten-ish topics that didn’t make it into the rest of the book.......1485

#11 JShell (Java REPL)....1487

Why do you care?....1487

#10 Packages....1490

Packages prevent class name conflicts....1490

Preventing package name conflicts....1492

Compiling and running with packages....1495

#9 Immutability in Strings and Wrappers....1498

Why do you care that Strings are immutable?....1498

Why do you care that Wrappers are immutable?....1500

#8 Access levels and access modifiers (who sees what)....1500

#7 Varargs....1503

Why do you care?....1504

#6 Annotations....1505

Why do you care?....1505

#5 Lambdas and Maps....1507

Why do you care?....1508

#4 Parallel Streams....1510

Going parallel....1511

OK now what?....1511

Multithreading is taken care of....1512

Do not use parallel everywhere!....1512

#3 Enumerations (also called enumerated types or enums)....1513

Who’s in the band?....1513

The old way to fake an “enum”:....1513

#2 Local Variable Type Inference (var)....1516

Type inference, NOT dynamic types....1517

Someone has to read your code....1517

Tip: Better with useful variable names....1518

Tip: Variable will be the concrete type....1518

Tip: Don’t use var with the diamond operator....1518

#1 Records....1519

Why do you care?....1519

Index....1525

Authors of Head First Java and Creators of the Head First series....1593

Co-author of Head First Java, 3rd Edition....1596

What will you learn from this book?

Head First Java is a complete learning experience in Java and object-oriented programming. With this book, you'll learn the Java language with a unique method that goes beyond how-to manuals and helps you become a great programmer. Through puzzles, mysteries, and soul-searching interviews with famous Java objects, you'll quickly get up to speed on Java's fundamentals and advanced topics including lambdas, streams, generics, threading, networking, and the dreaded desktop GUI. If you have experience with another programming language, Head First Java will engage your brain with more modern approaches to coding--the sleeker, faster, and easier to read, write, and maintain Java of today.

What's so special about this book?

If you've read a Head First book, you know what to expect--a visually rich format designed for the way your brain works. If you haven't, you're in for a treat. With Head First Java, you'll learn Java through a multisensory experience that engages your mind, rather than by means of a text-heavy approach that puts you to sleep.


Похожее:

Список отзывов:

Нет отзывов к книге.