Beginning Programming with Java For Dummies - Barry Burd

Beginning Programming with Java For Dummies

(Autor)

Buch | Softcover
560 Seiten
2017 | 5th Edition
John Wiley & Sons Inc (Verlag)
978-1-119-23553-8 (ISBN)
29,21 inkl. MwSt
zur Neuauflage
  • Titel erscheint in neuer Auflage
  • Artikel merken
Zu diesem Artikel existiert eine Nachauflage
Learn to speak the Java language like the pros Are you new to programming and have decided that Java is your language of choice? Are you a wanna-be programmer looking to learn the hottest lingo around? Look no further! Beginning Programming with Java For Dummies, 5th Edition is the easy-to-follow guide you'll want to keep in your back pocket as you work your way toward Java mastery! In plain English, it quickly and easily shows you what goes into creating a program, how to put the pieces together, ways to deal with standard programming challenges, and so much more. Whether you're just tooling around or embarking on a career, this is the ideal resource you'll turn to again and again as you perfect your understanding of the nuances of this popular programming language. Packed with tons of step-by-step instruction, this is the only guide you need to start programming with Java like a pro.
* Updated for Java 9, learn the language with samples and the Java toolkit * Familiarize yourself with decisions, conditions, statements, and information overload * Differentiate between loops and arrays, objects and classes, methods, and variables * Find links to additional resources Once you discover the joys of Java programming, you might just find you're hooked. Sound like fun? Here's the place to start.

Barry Burd, PhD, has been a professor in the Department of Mathematics and Computer Science at Drew University since 1980. He has lectured at conferences in the United States, Europe, Australia, and Asia, and hosts podcasts on various software and technology topics. Dr. Burd also authored Java Programming for Android Developers For Dummies.

Introduction 1

About This Book 1

How to Use This Book 2

Conventions Used in This Book 2

What You Don’t Have to Read 3

Foolish Assumptions 4

How This Book Is Organized 4

Part 1: Getting Started with Java Programming 5

Part 2: Writing Your Own Java Programs 5

Part 3: Controlling the Flow 5

Part 4: Using Program Units 5

Part 5: The Part of Tens 6

Icons Used in This Book 6

Beyond the Book 7

Where to Go from Here 7

Part 1: Getting Started with Java Programming 9

Chapter 1: Getting Started 11

What’s It All About? 11

Telling a computer what to do 12

Pick your poison 13

From Your Mind to the Computer’s Processor 14

Translating your code 14

Running code 15

Code you can use 20

Your Java Programming Toolset 21

A tool for creating code 22

What’s already on your hard drive? 22

Chapter 2: Setting Up Your Computer 23

If You Don’t Like Reading Instructions 24

Getting This Book’s Sample Programs 26

Setting Up Java 27

Downloading and installing Java 29

If you want to find Java on your computer 34

Setting Up the Eclipse Integrated Development Environment 40

Downloading Eclipse 41

Installing Eclipse 43

Running Eclipse for the first time 44

Importing This Book’s Sample Programs 50

What’s Next? 53

Chapter 3: Running Programs 55

Running a Canned Java Program 55

Typing and Running Your Own Code 60

Separating your programs from mine 61

Writing and running your program 62

What’s All That Stuff in Eclipse’s Window? 71

Understanding the big picture 71

Views, editors, and other stuff 72

What’s inside a view or an editor? 74

Returning to the big picture 76

Part 2: Writing Your Own Java Programs 79

Chapter 4: Exploring the Parts of a Program 81

Checking Out Java Code for the First Time 81

Behold! A program! 82

What the program’s lines say 83

The Elements in a Java Program 84

Keywords 85

Identifiers that you or I can define 87

Identifiers with agreed-upon meanings 88

Literals 89

Punctuation 90

Comments 91

Understanding a Simple Java Program 93

What is a method? 93

The main method in a program 96

How you finally tell the computer to do something 97

The Java class 99

Chapter 5: Composing a Program 103

Computers Are Stupid 104

A Program to Echo Keyboard Input 105

Typing and running a program 106

How the EchoLine program works 109

Getting numbers, words, and other things 110

Type three lines of code and don’t look back 112

Expecting the Unexpected 114

Diagnosing a problem 115

What problem? I don’t see a problem 125

Chapter 6: Using the Building Blocks: Variables, Values, and Types 129

Using Variables 130

Using a variable 131

Understanding assignment statements 132

To wrap or not to wrap? 132

What Do All Those Zeros and Ones Mean? 134

Types and declarations 135

What’s the point? 136

Reading Decimal Numbers from the Keyboard 137

Though these be methods, yet there is madness in ’t 138

Methods and assignments 138

Variations on a Theme 140

Moving variables from place to place 140

Combining variable declarations 142

Experimenting with JShell 143

Launching the JShell program 144

Using JShell 145

Chapter 7: Numbers and Types 151

Using Whole Numbers 151

Reading whole numbers from the keyboard 153

What you read is what you get 154

Creating New Values by Applying Operators 156

Finding a remainder 156

The increment and decrement operators 163

Assignment operators 169

Size Matters 171

Chapter 8: Numbers? Who Needs Numbers? 175

Characters 176

I digress 177

One character only, please 179

Variables and recycling 179

When not to reuse a variable 181

Reading characters 183

The boolean Type 187

Expressions and conditions 188

Comparing numbers; comparing characters 189

The Remaining Primitive Types 196

Part 3: Controlling the Flow 199

Chapter 9: Forks in the Road 201

Decisions, Decisions! 202

Making Decisions (Java if Statements) 203

Looking carefully at if statements 204

A complete program 207

Indenting if statements in your code 211

Variations on the Theme 212

Or else what? 212

Packing more stuff into an if statement 214

Some handy import declarations 216

Chapter 10: Which Way Did He Go? 221

Forming Bigger and Better Conditions 221

Combining conditions: An example 224

When to initialize? 226

More and more conditions 227

Using boolean variables 229

Mixing different logical operators together 231

Using parentheses 233

Building a Nest 234

Nested if statements 236

Cascading if statements 237

Enumerating the Possibilities 240

Creating an enum type 241

Using an enum type 241

Chapter 11: How to Flick a Virtual Switch 247

Meet the switch Statement 247

The cases in a switch statement 250

The default in a switch statement 251

Picky details about the switch statement 252

To break or not to break 255

Using Fall-Through to Your Advantage 257

Using a Conditional Operator 262

Chapter 12: Around and Around It Goes 265

Repeating Instructions over and over Again

(Java while Statements) 266

Following the action in a loop 268

No early bailout 270

Thinking about Loops (What Statements Go Where) 271

Finding some pieces 272

Assembling the pieces 274

Getting values for variables 275

From infinity to affinity 276

Thinking about Loops (Priming) 278

Working on the problem 281

Fixing the problem 284

Chapter 13: Piles of Files: Dealing with Information Overload 287

Running a Disk-Oriented Program 288

A sample program 290

Creating code that messes with your hard drive 292

Running the sample program 296

Troubleshooting problems with disk files 298

Writing a Disk-Oriented Program 301

Reading from a file 302

Writing to a file 303

Writing, Rewriting, and Rerewriting 306

Chapter 14: Creating Loops within Loops 309

Paying Your Old Code a Little Visit 310

Reworking some existing code 311

Running your code 312

Creating Useful Code 312

Checking for the end of a file 313

How it feels to be a computer 315

Why the computer accidentally pushes past the end of the file 317

Solving the problem 318

Chapter 15: The Old Runaround 325

Repeating Statements a Certain Number of Times (Java for Statements) 326

The anatomy of a for statement 328

Initializing a for loop 329

Using Nested for Loops 332

Repeating Until You Get What You Need (Java do Statements) 338

Getting a trustworthy response 339

Deleting a file 340

Using Java’s do statement 342

A closer look at the do statement 343

Repeating with Predetermined Values (Java’s Enhanced for Statement) 345

Creating an enhanced for loop 345

Nesting the enhanced for loops 347

Chapter 16: Using Loops and Arrays 353

Some Loops in Action 353

Deciding on a loop’s limit at runtime 355

Using all kinds of conditions in a for loop 358

Reader, Meet Arrays; Arrays, Meet the Reader 360

Storing values in an array 364

Creating a report 365

Initializing an array 367

Working with Arrays 368

Looping in Style 372

Deleting Several Files 373

Part 4: Using Program Units 381

Chapter 17: Programming with Objects and Classes 383

Creating a Class 384

Reference types and Java classes 385

Using a newly defined class 386

Running code that straddles two separate files 387

Why bother? 389

From Classes Come Objects 389

Understanding (or ignoring) the subtleties 392

Making reference to an object’s parts 392

Creating several objects 393

Another Way to Think about Classes 396

Classes, objects, and tables 396

Some questions and answers 397

What’s Next? 398

Chapter 18: Using Methods and Fields from a Java Class 401

The String Class 402

A simple example 402

Putting String variables to good use 403

Reading and writing strings 405

Using an Object’s Methods 406

Comparing strings 409

The truth about classes and methods 410

Calling an object’s methods 412

Combining and using data 412

Static Methods 413

Calling static and non-static methods 415

Turning strings into numbers 415

Turning numbers into strings 417

How the NumberFormat works 419

Your country; your currency 419

Understanding the Big Picture 421

Packages and import declarations 421

Shedding light on the static darkness 423

Barry makes good on an age-old promise 424

Chapter 19: Creating New Java Methods 431

Defining a Method within a Class 431

Making a method 432

Examining the method’s header 433

Examining the method’s body 434

Calling the method 435

The flow of control 436

Using punctuation 437

The versatile plus sign 438

Let the Objects Do the Work 441

Passing Values to Methods 442

Handing off a value 445

Working with a method header 446

How the method uses the object’s values 447

Passing more than one parameter 448

Getting a Value from a Method 450

An example 450

How return types and return values work 452

Working with the method header (again) 454

Chapter 20: Oooey GUI Was a Worm 457

The Java Swing Classes 458

Showing an image on the screen 459

Just another class 462

The Swing Classes: Round 2 467

Extending a class 468

Code Soup: Mixing XML with Java 470

Using JavaFX and Scene Builder 473

Installing Scene Builder 473

Installing e(fx)clipse 474

Creating a bare-bones JavaFX project 475

Running your bare-bones JavaFX project 476

Adding Stuff to Your JavaFX Project 477

Taking Action 482

Part 5: The Part of Tens 489

Chapter 21: Ten Websites for Java 491

This Book’s Website 491

The Horse’s Mouth 491

Finding News, Reviews, and Sample Code 492

Looking for Java Jobs 492

Got a Question? 492

Chapter 22: Ten Useful Classes in the Java API 493

ArrayList 493

File 494

Integer 494

JFrame 494

JOptionPane 495

Math 496

NumberFormat 496

Scanner 497

String 497

System 497

Index 499

Erscheinungsdatum
Verlagsort New York
Sprache englisch
Maße 191 x 232 mm
Gewicht 738 g
Themenwelt Informatik Programmiersprachen / -werkzeuge Java
Informatik Software Entwicklung Objektorientierung
Mathematik / Informatik Informatik Web / Internet
ISBN-10 1-119-23553-7 / 1119235537
ISBN-13 978-1-119-23553-8 / 9781119235538
Zustand Neuware
Haben Sie eine Frage zum Produkt?
Mehr entdecken
aus dem Bereich
mit über 150 Workouts in Java und Python

von Luigi Lo Iacono; Stephan Wiefling; Michael Schneider

Buch (2023)
Carl Hanser (Verlag)
29,99
Einführung, Ausbildung, Praxis

von Christian Ullenboom

Buch | Hardcover (2023)
Rheinwerk (Verlag)
49,90