售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Programming Kotlin
Programming Kotlin
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Getting Started with Kotlin
Using the command line to compile and run Kotlin code
Kotlin runtime
The REPL
Kotlin for scripting
Kotlin with Gradle
Kotlin with Maven
IntelliJ and Kotlin
Eclipse and Kotlin
Mixing Kotlin and Java in a project
Summary
2. Kotlin Basics
Vals and vars
Type inference
Basic types
Numbers
Booleans
Chars
Strings
Arrays
Comments
Packages
Imports
Wildcard imports
Import renaming
String templates
Ranges
Loops
Exception handling
Instantiating classes
Referential equality and structural equality
This expression
Scope
Visibility modifiers
Private
Protected
Internal
Control flow as expressions
Null syntax
Smart casts
Explicit casting
When expression
When (value)
When without argument
Function Return
Type hierarchy
Summary
3. Object-Oriented Programming in Kotlin
Classes
Access levels
Nested classes
Data classes
Enum classes
Static methods and companion objects
Interfaces
Inheritance
Visibility modifiers
Abstract classes
Interface or abstract class
Polymorphism
Overriding rules
Inheritance versus composition
Class delegation
Sealed classes
Summary
4. Functions in Kotlin
Defining functions
Single expression functions
Member functions
Local functions
Top-level functions
Named parameters
Default parameters
Extension functions
Extension function precedence
Extension functions on nulls
Member extension functions
Overriding member extension functions
Companion object extensions
Multiple return values
Infix functions
Operators
Operator overloading
Basic operators
In/contains
Get/set
Invoke
Comparison
Assignment
Java interop
Function literals
Tail recursive functions
Varargs
Spread operator
Standard library functions
Apply
Let
With
Run
Lazy
Use
Repeat
Require/assert/check
Generic functions
Pure functions
Java from Kotlin
Getters and setters
Single abstract methods
Escaping Kotlin identifiers
Java void methods
Kotlin from Java
Top-level functions
Default parameters
Object and static methods
Erasure naming
Checked exceptions
Summary
5. Higher Order Functions and Functional Programming
Higher order functions
Returning a function
Function assignment
Closures
Anonymous functions
Function references
Top-level function references
Member and extension function references
Bound references
Function-literal receivers
Functions in the JVM
Bytecode
Function composition
Inline functions
Noinline
Currying and partial application
Currying in action
Adding currying support
Memoization
Implementing memoization
Type alias
Either
Fold
Projection
Further projection functions
Custom DSLs
Infix functions as keywords
Using function receivers in a DSL
Validation and error accumulation
Summary
6. Properties
Why use properties?
Syntax and variations
Visibility
Late initialization
Delegated properties
Lazy initializations
Lateinit versus lazy
Observables
A non-null property delegate
Properties or methods?
Summary
7. Null Safety, Reflection, and Annotations
Nullable types
Smart cast
Safe null access
Force operator
Elvis operator
Safe casting
Optionals
Creating and returning an Optional
Using an Optional
Reflection
KClass
Instantiation using reflection
Constructors
Instantiation with callBy
Objects and companions
Useful KClass properties
Reflective functions and properties
Invoking a function reflectively
Declared and undeclared
Annotations
Annotation parameters
Standard annotations
@JvmName
@JvmStatic
@Throws
@JvmOverloads
Runtime annotation discovery
Summary
8. Generics
Parameterised functions
Parameterized types
Bounded polymorphism
Upper bounds
Multiple bounds
Type variance
Invariance
Covariance
Covariant return
Contravariance
Variance overview
Nothing type
Type projection
Type erasure
Type reification
Recursive type bounds
Algebraic data types
Summary
9. Data Classes
Automatic creation of getters and setters
The copy method
toString out of the box
hashCode and equals methods generated for you
Destructed declarations
Destructing types
Data class definition rules
Limitations
Summary
10. Collections
Class hierarchy
Arrays
Lists
Maps
Sets
Read-only views
Indexed access
Sequences
Summary
11. Testing in Kotlin
Getting started
Choosing a spec
Matchers
String matchers
Collection matchers
Floating point matchers
Expecting exceptions
Combining matchers
Custom matchers
Inspectors
Interceptors
The test case interceptor
The spec interceptor
Project config
Property testing
Specifying a generator
A custom generator
Table-driven testing
Testing non-deterministic code
Tags, conditions, and config
Config
Conditions
Tags
One instance
Resources
Summary
12. Microservices with Kotlin
Definition
Drawbacks
Why microservices?
Lagom
Defining services
Implementing a Lagom service
Summary
13. Concurrency
Threads
Blocking
Creating a thread
Stopping a thread
Thread interrupts
CPU-bound versus I/O-bound
Deadlocks and livelocks
Executors
Race conditions
Monitors
Locks
Read-write locks
Semaphores
The bounded buffer problem
Concurrent collections
ConcurrentHashMap
A blocking queue
Atomic variables
CountDownLatch
Cyclic Barrier
Non-blocking I/O and asynchronous programming
Futures
Summary
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜