𝔖 Scriptorium
✦   LIBER   ✦

πŸ“

Learn Java for Android Development: Java 8 and Android

✍ Scribed by Friesen, Jeff


Publisher
Apress
Year
2014
Tongue
English
Leaves
1190
Edition
3rd New edition
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Learn Java for Android Development, Third Edition, is an update of a strong selling book that now includes a primer on Android app development (in Chapter 1 and Appendix C, which is distributed in the book's code archive). This book teaches programmers the essential Java language skills necessary for effectively picking up and using the new Android SDK platform to build mobile, embedded, and even PC apps, especially game apps.Android development is hot, and many programmers are interested in joining the fun. However, because this technology is based on Java, you should first obtain a solid grasp of the Java language and its APIs in order to improve your chances of succeeding as an effective Android app developer. This book helps you do that.

Each of the book's 16 chapters provides an exercise section that gives you the opportunity to reinforce your understanding of the chapter's material. Answers to the book's more than 700 exercises are provided in an appendix. A second appendix provides a significant game-oriented Java application, which you can convert into an Android app.

Once you complete this one-of-a-kind book written by Jeff Friesen, an expert Java developer and JavaWorld.com columnist, you should be ready to begin your indie or professional Android app development journey.

✦ Table of Contents


Contents at a Glance......Page 3
Contents......Page 1175
About the Author......Page 1188
About the TechnicalReviewer......Page 1189
Acknowledgments......Page 1190
Introduction......Page 5
Chapter 1: Getting Started with Java......Page 9
Java Is a Language......Page 10
Java Is a Platform......Page 12
Java SE, Java EE, and Java ME......Page 14
Installing the JDK and Exploring Example Applications......Page 15
Hello, World!......Page 17
DumpArgs......Page 19
EchoText......Page 21
Installing and Exploring the Eclipse IDE......Page 23
What Is Android?......Page 28
History of Android......Page 29
Android Architecture......Page 32
Android Says Hello......Page 36
Summary......Page 38
Learning Application Structure......Page 39
Multiline Comments......Page 41
Javadoc Comments......Page 42
Learning Identifiers......Page 45
Primitive Types......Page 46
Array Types......Page 49
Learning Variables......Page 50
Simple Expressions......Page 51
Compound Expressions......Page 57
Additive Operators......Page 62
Array Index Operator......Page 64
Bitwise Operators......Page 65
Cast Operator......Page 67
Conditional Operators......Page 69
Equality Operators......Page 70
Logical Operators......Page 71
Member Access Operator......Page 72
Multiplicative Operators......Page 73
Shift Operators......Page 74
Precedence and Associativity......Page 75
Learning Statements......Page 78
If Statement......Page 79
If-Else Statement......Page 80
Switch Statement......Page 83
Loop Statements......Page 84
For Statement......Page 85
While Statement......Page 86
Do-While Statement......Page 88
Break and Labeled Break Statements......Page 89
Continue and Labeled Continue Statements......Page 91
Summary......Page 94
Declaring Classes......Page 96
Classes and Applications......Page 98
Constructing Objects......Page 99
Explicit Constructors......Page 100
Objects and Applications......Page 104
Encapsulating State and Behaviors......Page 105
Declaring and Accessing Class Fields......Page 106
Declaring and Accessing Instance Fields......Page 108
Reviewing Field-Access Rules......Page 113
Declaring and Invoking Class Methods......Page 114
Declaring and Invoking Instance Methods......Page 116
Returning from a Method via the Return Statement......Page 118
Chaining Together Instance Method Calls......Page 120
Passing Arguments to Methods......Page 121
Invoking Methods Recursively......Page 122
Overloading Methods......Page 123
Reviewing Method-Invocation Rules......Page 125
Hiding Information......Page 126
Class Initializers......Page 131
Instance Initializers......Page 133
Initialization Order......Page 135
Collecting Garbage......Page 138
Revisiting Arrays......Page 141
Summary......Page 146
Building Class Hierarchies......Page 148
Extending Classes......Page 149
The Ultimate Superclass......Page 155
Cloning......Page 156
Equality......Page 159
Finalization......Page 161
Hash Codes......Page 163
Composition......Page 164
The Trouble with Implementation Inheritance......Page 165
Changing Form......Page 169
Upcasting and Late Binding......Page 170
Abstract Classes and Abstract Methods......Page 174
Downcasting and Runtime Type Identification......Page 176
Covariant Return Types......Page 179
Declaring Interfaces......Page 181
Implementing Interfaces......Page 183
Extending Interfaces......Page 187
Why Use Interfaces?......Page 188
Summary......Page 194
Static Member Classes......Page 196
Nonstatic Member Classes......Page 200
Anonymous Class es......Page 204
Local Class es......Page 207
Inner Classes and Memory Leaks......Page 209
Interfaces within Classes and Classes within Interfaces......Page 210
Mastering Packages......Page 212
Package Names Must Be Unique......Page 213
The Import Statement......Page 214
Runtime Search......Page 216
Playing with Packages......Page 217
Mastering Static Imports......Page 222
Mastering Exceptions......Page 224
Error Codes vs. Objects......Page 225
The Throwable Class Hierarchy......Page 226
Checked Exceptions vs. Runtime Exceptions......Page 228
Custom Exception Classes......Page 229
Throwing Exceptions......Page 230
Handling Exceptions......Page 233
Handling Multiple Exception Types......Page 234
Performing Cleanup......Page 236
Summary......Page 241
Mastering Assertions......Page 242
Declaring Assertions......Page 243
Internal Invariants......Page 244
Control-Flow Invariants......Page 246
Preconditions......Page 247
Postconditions......Page 249
Avoiding Assertions......Page 250
Enabling and Disabling Assertions......Page 251
Discovering Annotations......Page 252
Declaring Annotation Types and Annotating Source Code......Page 255
Using Meta-Annotations in Annotation Type Declarations......Page 257
Processing Annotations......Page 260
Collections and the Need for Type Safety......Page 262
Generic Types......Page 265
Declaring and Using Your Own Generic Types......Page 266
Type Parameter Bounds......Page 269
The Need for Wildcards......Page 272
Generic Methods......Page 274
Arrays and Generics......Page 278
The Trouble with Traditional Enumerated Types......Page 280
The Enum Alternative......Page 282
Enhancing an Enum......Page 283
The Enum Class......Page 287
Extending the Enum Class......Page 288
Summary......Page 291
Exploring Math......Page 293
StrictMath and strictfp......Page 300
BigDecimal......Page 301
BigInteger......Page 307
Boolean......Page 311
Character......Page 313
Float and Double......Page 314
Integer, Long, Short, and Byte......Page 318
String......Page 320
StringBuffer and StringBuilder......Page 324
Exploring System......Page 328
Exploring Threads......Page 330
Runnable and Thread......Page 331
Synchronization......Page 341
Mutual Exclusion, Monitors, and Locks......Page 345
Visibility......Page 346
Waiting and Notification......Page 349
Deadlock......Page 355
Thread-Local Variables......Page 358
Summary......Page 363
Exploring Random......Page 365
Basic Terminology......Page 368
Reference and ReferenceQueue......Page 369
WeakReference......Page 371
PhantomReference......Page 372
The Class Entry Point......Page 374
Obtaining a Class Object......Page 378
Instantiating a Dynamically Loaded Class......Page 383
Constructor, Field, and Method......Page 384
Accessible Objects......Page 388
Package......Page 389
Exploring StringTokenizer......Page 394
Exploring Timer and TimerTask......Page 397
Timer in Depth......Page 398
TimerTask in Depth......Page 401
One-Shot Execution and Repeated Execution with Cancellation......Page 402
Summary......Page 405
Exploring Collections Framework Fundamentals......Page 407
Comparable vs. Comparator......Page 408
Iterable and Collection......Page 410
Iterator and the Enhanced For Loop Statement......Page 414
Autoboxing and Unboxing......Page 415
Exploring List s......Page 417
ArrayList......Page 421
LinkedList......Page 422
TreeSet......Page 425
HashSet......Page 426
EnumSet......Page 431
Exploring Sorted Sets......Page 434
Exploring Navigable Sets......Page 441
Exploring Queues......Page 444
PriorityQueue......Page 446
Exploring Deques......Page 449
ArrayDeque......Page 453
Exploring Maps......Page 454
TreeMap......Page 458
HashMap......Page 459
Overriding hashCode ()......Page 462
HashMap and Image Caches......Page 465
IdentityHashMap......Page 469
WeakHashMap......Page 471
EnumMap......Page 473
Exploring Sorted Maps......Page 474
Exploring Navigable Maps......Page 477
Exploring the Arrays and Collections Utility APIs......Page 481
Exploring the Legacy Collection APIs......Page 485
Summary......Page 492
Introducing the Concurrency Utilities......Page 493
Exploring Executors......Page 494
Countdown Latches......Page 503
Cyclic Barriers......Page 506
Exchangers......Page 511
Semaphores......Page 515
Exploring the Concurrent Collections......Page 521
Demonstrating BlockingQueue and ArrayBlockingQueue......Page 522
Exploring the Locking Framework......Page 524
Lock......Page 525
ReentrantLock......Page 527
Condition......Page 530
ReentrantReadWriteLock......Page 535
Exploring Atomic Variables......Page 539
Improving Performance with the Concurrency Utilities......Page 541
Summary......Page 544
Working with the File API......Page 545
Constructing File Instances......Page 546
Learning About Stored Abstract Pathnames......Page 548
Learning About a Pathname’s File or Directory......Page 551
Obtaining Disk Space Information......Page 552
Listing Directories......Page 554
Creating and Manipulating Files and Directories......Page 556
Setting and Getting Permissions......Page 558
Exploring Miscellaneous Capabilities......Page 560
Working with the RandomAccessFile API......Page 562
Working with Streams......Page 573
Stream Classes Overview......Page 574
OutputStream and InputStream......Page 575
ByteArrayOutputStream and ByteArrayInputStream......Page 578
FileOutputStream and FileInputStream......Page 579
PipedOutputStream and PipedInputStream......Page 582
FilterOutputStream and FilterInputStream......Page 585
BufferedOutputStream and BufferedInputStream......Page 593
DataOutputStream and DataInputStream......Page 594
Object Serialization and Deserialization......Page 596
Default Serialization and Deserialization......Page 597
Custom Serialization and Deserialization......Page 602
Externalization......Page 608
PrintStream......Page 610
Standard I/O Revisited......Page 612
Working with Writers and Readers......Page 613
Writer and Reader Classes Overview......Page 614
Writer and Reader......Page 616
OutputStreamWriter and InputStreamReader......Page 617
FileWriter and FileReader......Page 618
Summary......Page 626
Chapter 12: Accessing Networks......Page 627
Accessing Networks via Sockets......Page 628
Socket Addresses......Page 630
Socket Options......Page 631
Socket and ServerSocket......Page 632
DatagramSocket and MulticastSocket......Page 638
URL and URLConnection......Page 645
URLEncoder and URLDecoder......Page 649
URI......Page 651
Normalization......Page 655
Resolution......Page 656
Relativization......Page 657
Accessing Network Interfaces and Interface Addresses......Page 658
Managing Cookies......Page 663
Summary......Page 668
Chapter 13: Migrating to New I/O......Page 670
Buffer and Its Children......Page 671
Buffer Creation......Page 675
Buffer Writing and Reading......Page 678
Flipping Buffers......Page 680
Marking Buffers......Page 682
Byte Ordering......Page 684
Direct Byte Buffers......Page 685
Channel and Its Children......Page 686
Scatter/Gather I/O......Page 691
File Channels......Page 694
Locking Files......Page 698
Mapping Files into Memory......Page 705
Transferring Bytes Among Channels......Page 709
Socket Channels......Page 711
Understanding Nonblocking Mode......Page 712
Exploring Server Socket Channels......Page 714
Exploring Socket Channels......Page 716
Exploring Datagram Channels......Page 719
Pipes......Page 725
Working with Selectors......Page 728
Selector Fundamentals......Page 729
Selector Demonstration......Page 733
Pattern, PatternSyntaxException, and Matcher......Page 737
Character Classes......Page 742
Capturing Groups......Page 743
Boundary Matchers and Zero-Length Matches......Page 744
Quantifiers......Page 745
A Brief Review of the Fundamentals......Page 748
Working with Charsets......Page 749
Charsets and the String Class......Page 755
Working with Formatter and Scanner......Page 756
Working with Formatter......Page 757
Working with Scanner......Page 761
Summary......Page 766
Chapter 14: Accessing Databases......Page 768
Introducing Java DB......Page 769
Java DB Installation and Configuration......Page 771
Java DB Demos......Page 772
Java DB Command-Line Tools......Page 774
Introducing SQLite......Page 777
Data Sources, Drivers, and Connections......Page 779
Exceptions......Page 782
Statement and ResultSet......Page 786
PreparedStatement......Page 790
CallableStatement......Page 793
Metadata......Page 799
Summary......Page 806
What Is XML?......Page 808
XML Declaration......Page 810
Elements and Attributes......Page 811
Character References and CDATA Sections......Page 813
Namespaces......Page 814
Comment and Processing Instructions......Page 818
Valid Documents......Page 819
Document Type Definition......Page 820
XML Schema......Page 825
Parsing XML Documents with SAX......Page 829
Exploring the SAX API......Page 830
Demonstrating the SAX API......Page 836
Creating a Custom Entity Resolver......Page 845
A Tree of Nodes......Page 848
Exploring the DOM API......Page 850
Parsing XML Documents......Page 852
Creating XML Documents......Page 858
Parsing XML Documents with XMLPULL V1......Page 860
Location Path Expressions......Page 864
General Expressions......Page 867
XPath and DOM......Page 868
Namespace Contexts......Page 873
Extension Functions and Function Resolvers......Page 875
Variables and Variable Resolvers......Page 878
Exploring the XSLT API......Page 880
Demonstrating the XSLT API......Page 883
Summary......Page 889
Focusing on Additional Language Features......Page 890
Switch-on-String......Page 891
Multicatch......Page 892
Automatic Resource Management......Page 893
Kinds of Classloaders......Page 896
Class-Loading Mechanics......Page 897
Playing with Classloaders......Page 898
Classloader Difficulties......Page 902
Classloaders and Resources......Page 904
Focusing on Console......Page 907
Focusing on Design Patterns......Page 910
Implementing Strategy......Page 911
Focusing on Double Brace Initialization......Page 914
Focusing on Fluent Interfaces......Page 915
Focusing on Immutability......Page 916
Focusing on Internationalization......Page 919
Locales......Page 920
Resource Bundles......Page 921
Property Resource Bundles......Page 924
List Resource Bundles......Page 927
Taking Advantage of Cache Clearing......Page 931
Taking Control of the getBundle( ) Methods......Page 937
Break Iterators......Page 940
Collators......Page 944
Dates, Time Zones, and Calendars......Page 946
Number Formatters......Page 953
Date Formatters......Page 956
Message Formatters......Page 958
Parsing......Page 961
Focusing on Logging......Page 963
Logging API Overview......Page 964
A Hierarchy of Loggers......Page 965
Logging Messages......Page 967
Filtering LogRecords......Page 973
Handlers and Formatters......Page 976
LogManager and Configuration......Page 979
ErrorManager......Page 982
Focusing on Preferences......Page 986
Exploring Preferences......Page 987
Focusing on Runtime and Process......Page 991
Creating a Hybrid Library......Page 995
Java Class......Page 996
Native Interface Library......Page 997
Testing the Hybrid Library......Page 999
Focusing on the ZIP API......Page 1000
Writing Files to a ZIP Archive......Page 1002
Reading Files from a ZIP Archive......Page 1005
Focusing on the JAR API......Page 1008
Summary......Page 1015
Chapter 1: Getting Started with Java......Page 1020
Chapter 2: Learning Language Fundamentals......Page 1022
Chapter 3: Discovering Classes and Objects......Page 1025
Chapter 4: Discovering Inheritance, Polymorphism, and Interfaces......Page 1031
Chapter 5: Mastering Advanced Language Features, Part 1......Page 1039
Chapter 6: Mastering Advanced Language Features, Part 2......Page 1046
Chapter 7: Exploring the Basic APIs, Part 1......Page 1051
Chapter 8: Exploring the Basic APIs, Part 2......Page 1059
Chapter 9: Exploring the Collections Framework......Page 1064
Chapter 10: Exploring the Concurrency Utilities......Page 1070
Chapter 11: Performing Classic I/O......Page 1078
Chapter 12: Accessing Networks......Page 1088
Chapter 13: Migrating to New I/O......Page 1093
Chapter 14: Accessing Databases......Page 1101
Chapter 15: Parsing, Creating, and Transforming XML Documents......Page 1105
Chapter 16: Focusing on Odds and Ends......Page 1121
Understanding Four of a Kind......Page 1131
Modeling Four of a Kind in Pseudocode......Page 1132
Converting Pseudocode to Java Code......Page 1133
Compiling, Running, and Distributing FourOfAKind......Page 1149
Index......Page 1153

✦ Subjects


Computer Science;Programming;Reference;Science;Technology


πŸ“œ SIMILAR VOLUMES


Learn Java for Android Development
✍ Jeff Friesen πŸ“‚ Library πŸ“… 2010 πŸ› Apress 🌐 English

Android development is hot, and many programmers are interested in joining the fun. However, because this technology is based on Java, you should first obtain a solid grasp of the Java language and its foundational APIs to improve your chances of succeeding as an Android app developer. After al

Learn Java for Android development
✍ Jeff Friesen πŸ“‚ Library πŸ“… 2013 πŸ› Apress 🌐 English

Android development is hot, and many programmers are interested in joining the fun. However, because this technology is based on Java, you should first obtain a solid grasp of the Java language and its foundational APIs to improve your chances of succeeding as an Android app developer. After all, yo

Learn Java for Android development
✍ Jeff Friesen πŸ“‚ Library πŸ“… 2013 πŸ› Apress 🌐 English

Android development is hot, and many programmers are interested in joining the fun. However, because this technology is based on Java, you should first obtain a solid grasp of the Java language and its foundational APIs to improve your chances of succeeding as an Android app developer. After all, yo

Learn Java for Android Development
✍ Jeff Friesen πŸ“‚ Library πŸ“… 2013 πŸ› Apress 🌐 English

<p> Android development is hot, and many programmers are interested in joining the fun. However, because this technology is based on Java, you should first obtain a solid grasp of the Java language and its foundational APIs to improve your chances of succeeding as an Android app developer. After

Learn Java for Android Development
✍ Jeff Friesen πŸ“‚ Library πŸ“… 2013 πŸ› Apress 🌐 English

<p> Android development is hot, and many programmers are interested in joining the fun. However, because this technology is based on Java, you should first obtain a solid grasp of the Java language and its foundational APIs to improve your chances of succeeding as an Android app developer. After

Learn Java for Android Development
✍ Jeff Friesen πŸ“‚ Library πŸ“… 2014 πŸ› Apress 🌐 English

Learn Java for Android Development, Third Edition is an update of a strong selling book that now includes the newest Java 8 APIs available in the latest Android SDK 5 (Key Lime Pie). This book teaches programmers the essential Java language skills necessary for effectively picking up and using the n