Sams Teach Yourself Java in 21 Days (Covers Java 11/12)
Häftad, Engelska, 2020
399 kr
In arenas ranging from enterprise development to Android app programming, Java remains one of the world's most popular programming languages. Sams Teach Yourself Java in 21 Days helps the serious learner gain true mastery over the new Java 9.
In this book's straightforward, step-by-step approach, each lesson builds on everything that's come before, helping readers learn Java's core features and techniques from the ground up. Friendly, accessible, and conversational, this book offers a practical grounding in the language, without ever becoming overwhelming or intimidating.
Week 1 introduces the basic building blocks of the Java programming language: keywords, operators, class and object definitions, packages, interfaces, exceptions, and threads.
Week 2 covers the Swing graphical user interface class libraries and the important classes that support data structures, string handling, dates and times.
Week 3 ventures into the hottest areas of Java programming: web services, Java servlets, network programming, database programming and Android development.
Produktinformation
- Utgivningsdatum2020-02-28
- Mått174 x 230 x 36 mm
- Vikt1 046 g
- FormatHäftad
- SpråkEngelska
- SerieSams Teach Yourself
- Antal sidor672
- Upplaga8
- FörlagPearson Education
- ISBN9780672337956
Tillhör följande kategorier
Rogers Cadenhead is an experienced software developer who has written more than 30 books on programming and web publishing, including Sams Teach Yourself Java in 24 Hours and Absolute Beginner’s Guide to Minecraft Mods Programming. He creates applications on the ServiceNow cloud platform, using Java and JavaScript. He maintains this book’s official website, at www.java21days.com, and can be contacted on Twitter at @rcade and on his weblog, at http://workbench.cadenhead.org.
- Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1How This Book Is Organized ....................................................................................................2Who Should Read This Book ...................................................................................................4Conventions Used in This Book ...............................................................................................5PART I The Java Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7LESSON 1: Getting Started with Java 9The Java Language ..................................................................................................................10Object-Oriented Programming ................................................................................................13Objects and Classes .................................................................................................................14Attributes and Behavior ..........................................................................................................16Organizing Classes and Class Behavior ..................................................................................25Summary .................................................................................................................................32Q&A ........................................................................................................................................33Quiz .........................................................................................................................................34Certification Practice ...............................................................................................................35Exercises ..................................................................................................................................35LESSON 2: The ABCs of Programming 37Statements and Expressions ....................................................................................................38Variables and Data Types ........................................................................................................38Comments................................................................................................................................46Literals .....................................................................................................................................47String Literals ...............................................................................................................50Expressions and Operators ......................................................................................................51String Arithmetic .....................................................................................................................60Summary .................................................................................................................................62Q&A ........................................................................................................................................62Quiz .........................................................................................................................................63Certification Practice ...............................................................................................................64Exercises ..................................................................................................................................65LESSON 3: Working with Objects 67Creating New Objects .............................................................................................................68Using Class and Instance Variables ........................................................................................72Calling Methods ......................................................................................................................75Class Methods ..............................................................................................................79References to Objects ..............................................................................................................80Casting Objects and Primitive Types ......................................................................................82Converting Primitive Types to Objects and Vice Versa ................................................85Comparing Object Values and Classes ....................................................................................87Summary .................................................................................................................................89Q&A ........................................................................................................................................90Quiz .........................................................................................................................................91Certification Practice ...............................................................................................................91Exercises ..................................................................................................................................92LESSON 4: Lists, Logic, and Loops 93Arrays ......................................................................................................................................94Block Statements ...................................................................................................................101if Conditionals .....................................................................................................................102Switch Conditionals ..............................................................................................................103The Ternary Operator ............................................................................................................110for Loops ..............................................................................................................................111while and do Loops ..............................................................................................................114xii Sams Teach Yourself Java in 21 DaysBreaking Out of Loops ..........................................................................................................117Summary ...............................................................................................................................119Q&A ......................................................................................................................................119Quiz .......................................................................................................................................120Certification Practice .............................................................................................................121Exercises ................................................................................................................................122LESSON 5: Creating Classes and Methods 123Defining Classes ....................................................................................................................124Creating Instance and Class Variables ..................................................................................124Creating Methods ..................................................................................................................126Creating Java Applications ....................................................................................................133Java Applications and Arguments .........................................................................................134Creating Methods with the Same Name ...............................................................................137Constructors ..........................................................................................................................142Overriding Methods ..............................................................................................................146Summary ...............................................................................................................................150Q&A ......................................................................................................................................151Quiz .......................................................................................................................................152Certification Practice .............................................................................................................153Exercises ................................................................................................................................154LESSON 6: Packages, Interfaces, and Other Class Features 155Modifiers ...............................................................................................................................156Static Variables and Methods ................................................................................................162Final Classes, Methods, and Variables ..................................................................................165Abstract Classes and Methods ..............................................................................................167Packages ................................................................................................................................167Creating Your Own Packages ................................................................................................171Interfaces ...............................................................................................................................174Creating and Extending Interfaces ........................................................................................177Summary ...............................................................................................................................185Q&A ......................................................................................................................................186Quiz .......................................................................................................................................186Certification Practice .............................................................................................................187Exercises ................................................................................................................................188LESSON 7: Exceptions and Threads 189Exceptions .............................................................................................................................190Managing Exceptions ............................................................................................................193Declaring Methods That Might Throw Exceptions ..............................................................200Creating and Throwing Exceptions .......................................................................................205When Not to Use Exceptions ................................................................................................208Threads ..................................................................................................................................209Summary ...............................................................................................................................216Q&A ......................................................................................................................................217Quiz .......................................................................................................................................217Certification Practice .............................................................................................................218Exercises ................................................................................................................................219PART II: The Java Class Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .221LESSON 8: Data Structures 223Moving Beyond Arrays .........................................................................................................224Java Structures .......................................................................................................................224Generics .................................................................................................................................244Enumerations .........................................................................................................................247Summary ...............................................................................................................................249Q&A ......................................................................................................................................249Quiz .......................................................................................................................................250Certification Practice .............................................................................................................251Exercises ................................................................................................................................252LESSON 9: Creating a Graphical User Interface 253Creating an Application ........................................................................................................254Working with Components ...................................................................................................261Lists .......................................................................................................................................274The Java Class Library ..........................................................................................................276Summary ...............................................................................................................................278Q&A ......................................................................................................................................279Quiz .......................................................................................................................................279Certification Practice .............................................................................................................280Exercises ................................................................................................................................281LESSON 10: Building an Interface 283Swing Features ......................................................................................................................284Summary ...............................................................................................................................304Q&A ......................................................................................................................................304Quiz .......................................................................................................................................305Certification Practice .............................................................................................................306Exercises ................................................................................................................................307LESSON 11: Arranging Components on a User Interface 309Basic Interface Layout ..........................................................................................................310Mixing Layout Managers ......................................................................................................320Card Layout ...........................................................................................................................321Summary ...............................................................................................................................329Q&A ......................................................................................................................................330Quiz .......................................................................................................................................331Certification Practice .............................................................................................................331Exercises ................................................................................................................................332LESSON 12: Responding to User Input 333Event Listeners ......................................................................................................................334Working with Methods ..........................................................................................................339Using Inner Classes ....................................................................................................353Summary ...............................................................................................................................355Q&A ......................................................................................................................................355Quiz .......................................................................................................................................356Certification Practice .............................................................................................................357Exercises ................................................................................................................................358LESSON 13: Creating Java2D Graphics 359The Graphics2D Class ..........................................................................................................360Drawing Text .........................................................................................................................362Color ......................................................................................................................................366Drawing Lines and Polygons ................................................................................................369Summary ...............................................................................................................................378Q&A ......................................................................................................................................379Quiz .......................................................................................................................................379Certification Practice .............................................................................................................380Exercises ................................................................................................................................381LESSON 14: Developing Swing Applications 383Improving Performance with SwingWorker .........................................................................384Grid Bag Layout ....................................................................................................................389Summary ...............................................................................................................................398Q&A ......................................................................................................................................398Quiz .......................................................................................................................................398Certification Practice .............................................................................................................399Exercises ................................................................................................................................400PART III: Java Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .401LESSON 15: Using Inner Classes and Lambda Expressions 403Inner Classes .........................................................................................................................404Lambda Expressions .............................................................................................................413Variable Type Inference ........................................................................................................418Summary ...............................................................................................................................419Q&A ......................................................................................................................................420Quiz .......................................................................................................................................420Certification Practice .............................................................................................................421Exercises ................................................................................................................................422LESSON 16: Working with Input and Output 423Introduction to Streams .........................................................................................................424Byte Streams .........................................................................................................................426Filtering a Stream ..................................................................................................................431Character Streams .................................................................................................................440Files and Paths.......................................................................................................................445Summary ...............................................................................................................................447Q&A ......................................................................................................................................448Quiz .......................................................................................................................................448Certification Practice .............................................................................................................449Exercises ................................................................................................................................450LESSON 17: Communicating Over HTTP 451Networking in Java ................................................................................................................452The java.nio Package .........................................................................................................465Summary ...............................................................................................................................480Q&A ......................................................................................................................................480Quiz .......................................................................................................................................481Certification Practice .............................................................................................................482Exercises ................................................................................................................................482LESSON 18: Accessing Databases with JDBC and Derby 483Java Database Connectivity...................................................................................................484Summary ...............................................................................................................................501Q&A ......................................................................................................................................502Quiz .......................................................................................................................................502Certification Practice .............................................................................................................503Exercises ................................................................................................................................503LESSON 19: Reading and Writing RSS Feeds 505Using XML ...........................................................................................................................506Designing an XML Dialect ...................................................................................................508Processing XML with Java ...................................................................................................510Processing XML with XOM .................................................................................................510Summary ...............................................................................................................................525Q&A ......................................................................................................................................525Quiz .......................................................................................................................................526Certification Practice .............................................................................................................527Exercises ................................................................................................................................528LESSON 20: Making Web Service Requests 529Introduction to XML-RPC ....................................................................................................530Communicating with XML-RPC ..........................................................................................531Choosing an XML-RPC Implementation .............................................................................534Using an XML-RPC Web Service ........................................................................................536Creating an XML-RPC Web Service ....................................................................................539Summary ...............................................................................................................................545Q&A ......................................................................................................................................545Quiz .......................................................................................................................................546Certification Practice .............................................................................................................546Exercises ................................................................................................................................547LESSON 21: Writing a Game with Java 549Playing a Game .....................................................................................................................550Summary ...............................................................................................................................572Q&A ......................................................................................................................................572Quiz .......................................................................................................................................573Certification Practice .............................................................................................................574Exercises ................................................................................................................................575APPENDIXES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597APPENDIX A: Using the NetBeans Integrated Development Environment . . . . . . 599APPENDIX B: Fixing Package Not Visible Errors in NetBeans . . . . . . . . . . . . . . . . 609APPENDIX C: This Book’s Website. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613APPENDIX D: Using the Java Development Kit . . . . . . . . . . . . . . . . . . . . . . . . . . . 615APPENDIX E: Programming with the Java Development Kit . . . . . . . . . . . . . . . . . 6319780672337956, TOC, 11/18/2019