You are previewing Learn Java for Android Development, Second Edition.
O'Reilly logo
Learn Java for Android Development, Second Edition

Book Description

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, you will be busy learning the architecture of an Android app, the various Android-specific APIs, and Android-specific tools. If you do not already know Java fundamentals, you will probably end up with a massive headache from also having to quickly cram those fundamentals into your knowledge base.

Learn Java for Android Development, Second Edition teaches programmers of any skill level the essential Java language and foundational Java API skills that must be learned to improve the programmer's chances of succeeding as an Android app developer. Each of the book's 14 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 500 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 book, you should be ready to dive into beginning Android app development. Maybe, start that journey with Apress' Beginning Android.

What you'll learn

  • The Java language: This book provides complete coverage of nearly every pre-Java version 7 language feature (native methods are briefly mentioned but not formally covered). Starting with basic language features (e.g., comments, types, expressions, and statements), you progress to those features related to classes and objects, followed by object-oriented features related to inheritance, polymorphism, and interfaces. You then explore the advanced language features for nested types, packages, static imports, exceptions, assertions, annotations, generics, and enums. Continuing, you investigate strictfp, synchronized, volatile, the enhanced for loop statement, autoboxing/unboxing, and transient fields.

  • Java APIs: In addition to Object and APIs related to exceptions, you explore Math, StrictMath, BigDecimal, BigInteger, String, StringBuffer/StringBuilder, Boolean, Character, Byte, Short, Integer, Long, Float, Double, Number, the Threads API, System, Runtime, Process, the Collections Framework, the Concurrency Utilities, Date, Formatter, Random, Scanner, the ZIP and JAR APIs, File, RandomAccessFile, stream classes, and writer/reader classes, InetAddress, SocketOptions, Socket, ServerSocket, DatagramSocket, MulticastSocket, URL, URLConnection, URLEncoder, URLDecoder, NetWorkInterface, InterfaceAddress, CookieHandler, CookieManager, CookieStore, CookiePolicy, Buffer, ByteBuffer, CharBuffer, DoubleBuffer,FloatBuffer, IntBuffer, LongBuffer, ShortBuffer, MappedByteBuffer, Channel, WritableByteChannel, ReadableByteChannel,ScatteringByteChannel, GatheringByteChannel, FileChannel, the Regular Expressions API, JDBC, and more.

  • Applying these: You will learn how to use the JDK's javac (compiler), java (application launcher), javadoc (Java documentation generator), and jar (Java archive creator, updater, and extractor) tools. You will also receive an introduction to the Eclipse integrated development environment, which is the official standard for developing Android apps.

Who this book is for

This book is for any programmer - including existing Java programmers and Objective-C-based iPhone and iPad programmers - of any skill level who needs to obtain a solid understanding of the Java language and foundational Java APIs before jumping into Android app development.

Table of Contents

  1. Title Page
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. About the Author
  6. About the Technical Reviewers
  7. Acknowledgments
  8. Introduction
  9. Chapter 1: Getting Started With Java
    1. What Is Java?
    2. Installing and Exploring the JDK
    3. Installing and Exploring the Eclipse IDE
    4. Overview of Java APIs
    5. Summary
  10. Chapter 2: Learning Language Fundamentals
    1. Learning Comments
    2. Learning Identifiers
    3. Learning Types
    4. Learning Variables
    5. Learning Expressions
    6. Learning Statements
    7. Summary
  11. Chapter 3: Discovering Classes and Objects
    1. Declaring Classes and Instantiating Objects
    2. Encapsulating State and Behaviors
    3. Initializing Classes and Objects
    4. Collecting Garbage
    5. Revisiting Arrays
    6. Summary
  12. Chapter 4: Discovering Inheritance, Polymorphism, and Interfaces
    1. Building Class Hierarchies
    2. Changing Form
    3. Formalizing Class Interfaces
    4. Summary
  13. Chapter 5: Mastering Advanced Language Features Part 1
    1. Mastering Nested Types
    2. Mastering Packages
    3. Mastering Static Imports
    4. Mastering Exceptions
    5. Summary
  14. Chapter 6: Mastering Advanced Language Features Part 2
    1. Mastering Assertions
    2. Mastering Annotations
    3. Mastering Generics
    4. Mastering Enums
    5. Summary
  15. Chapter 7: Exploring the Basic APIs Part 1
    1. Exploring the Math APIs
    2. Exploring String Management
    3. Obtaining Package Information
    4. Summary
  16. Chapter 8: Exploring the Basic APIs Part 2
    1. Exploring the Primitive Type Wrapper Classes
    2. Exploring Threads
    3. Exploring System Capabilities
    4. Summary
  17. Chapter 9: Exploring the Collections Framework
    1. Exploring Collections Framework Fundamentals
    2. Exploring Lists
    3. Exploring Sets
    4. Exploring Sorted Sets
    5. Exploring Navigable Sets
    6. Exploring Queues
    7. Exploring Deques
    8. Exploring Maps
    9. Exploring Sorted Maps
    10. Exploring Navigable Maps
    11. Exploring the Arrays and Collections Utility APIs
    12. Exploring the Legacy Collection APIs
    13. Summary
  18. Chapter 10: Exploring Additional Utility APIs
    1. Exploring the Concurrency Utilities
    2. Exploring the Date Class
    3. Exploring the Formatter Class
    4. Exploring the Random Class
    5. Exploring the Scanner Class
    6. Exploring the ZIP and JAR APIs
    7. Summary
  19. Chapter 11: Performing Classic I/O
    1. Working with the File API
    2. Working with the RandomAccessFile API
    3. Working with Streams
    4. Working with Writers and Readers
    5. Summary
  20. Chapter 12: Accessing Networks
    1. Accessing Networks via Sockets
    2. Accessing Networks via URLs
    3. Accessing Network Interfaces and Interface Addresses
    4. Managing Cookies
    5. Summary
  21. Chapter 13: Migrating to New I/O
    1. Working with Buffers
    2. Working with Channels
    3. Working With Regular Expressions
    4. Summary
  22. Chapter 14: Accessing Databases
    1. Introducing Java DB
    2. Introducing SQLite
    3. Accessing Databases via JDBC
    4. Summary
  23. Appendix A: Solutions to Exercises
    1. Chapter 1: Getting Started with Java
    2. Chapter 2: Learning Language Fundamentals
    3. Chapter 3: Discovering Classes and Objects
    4. Chapter 4: Discovering Inheritance, Polymorphism, and Interfaces
    5. Chapter 5: Mastering Advanced Language Features Part 1
    6. Chapter 6: Mastering Advanced Language Features Part 2
    7. Chapter 7: Exploring the Basic APIs Part 1
    8. Chapter 8: Exploring the Basic APIs Part 2
    9. Chapter 9: Exploring the Collections Framework
    10. Chapter 10: Exploring Additional Utility APIs
    11. Chapter 11: Performing Classic I/O
    12. Chapter 12: Accessing Networks
    13. Chapter 13: Migrating to New I/O
    14. Chapter 14: Accessing Databases
  24. Appendix B: Four of a Kind
    1. Understanding Four of a Kind
    2. Modeling Four of a Kind in Pseudocode
    3. Converting Pseudocode to Java Code
    4. Compiling, Running, and Distributing FourOfAKind
  25. Index