Modern-android-lab - Kotlin Language learning lab

Overview

kotlin-code-labs

Kotlin Language learning lab

Run the code with Kotlin Compiler:

$ kotlinc file.kt -include-runtime -d file.jar
$ java -jar file.jar

Kotlin is a cross-platform, statically typed, general purpose programming language with type inference. Kotlin is designed to interoperate fully with Java and the JVM version of Kotlin's standard library depends on the Java Class Library, but type inference allows its syntax to be more precise.

Topics

  • Basics
  • Concepts
  • Multiplatform development
  • Platforms
  • Standard Library
  • Kotlin Coroutines
  • Serialization
  • Ktor

Basic syntax

Package definition and imports

Package specification should be at the top of the source file.

package my.demo

import kotlin.text.*

// some code

It is not required to match directories and packages: Source files can be placed arbitrarily in the file system

Program entry point

An entry point of a Kotlin application is the main function

fun main(){
    println("Hello Kotlin")
}

Another form of main accepts a variable number of String arguments.

fun main(args: Array<String>){
    println(args.contentToString())
}

Print to the standard output

print prints its arguments to the standard output

print("Hello")
print("...hey hey have you seen episode")
print(43)

Functions

fun sum(a: Int, b: Int): Int {
    return a + b
}

A function body can be expression. Its return type is inferred.

fun sum(a: Int, b: Int) = a + b

A function that returns no meaningful value:

fun printSum(a: Int, b: Int): Unit {
    println("sum of $a and $b is ${a + b}")
}

Unit return type can be omitted

fun printSum(a: Int, b: Int){
    println("sum of $a and $b is ${a + b}")
}

Variables

Read-only local variables are defined using the keyword val.

val a: Int = 1
val b = 2
c = 3

Variables that can be reassigned use the var keyword

var x = 5
x += 3

Creating classes and instances

To define a class, use the class keyword

class shape

Properties of a class can be listed in its declaration or body

class Rectangle(var height: Double, var length: Double) {
    var perimeter = (height + length) * 2
}

The default constructor with parameters listed in the class declaration is available automatically

You might also like...
Learning app for Dagger-Hilt in android

Using Hilt in your Android app This folder contains the code which i learned by following this you YouTube Tutorial Introduction Dependency injection

This document will walk you through the steps for creating your Android app that runs a deep learning image classification model trained in Pocket AutoML and exported in TensorFlow Lite format
This document will walk you through the steps for creating your Android app that runs a deep learning image classification model trained in Pocket AutoML and exported in TensorFlow Lite format

Pocket AutoML: Tutorial for Creating an Android App for Image Classification with Deep Learning Translations English (this document) Русский Overview

FireApp is an open-source project that is built around Firebase Products, especially for learning purposes
FireApp is an open-source project that is built around Firebase Products, especially for learning purposes

FireApp is an open-source project that is built around Firebase Products, especially for learning purposes. This application is written entirely in Kotlin using Android Architecture Components and MVVM architecture pattern. You'll see in the code of this repo, how Firebase Products are working together.

Learning about architecture with implement TMDB Restful API

PopCorn Movie and Tv Show list application. Build for learning about architecture (maybe it's clean architecture, but i don't know it's clean or not.

A showcase music app for Android entirely written using Kotlin language

Bandhook Kotlin This project is a small replica of the app I developed some time ago. Bandhook can still be found on Play Store At the moment it will

An android app written in Kotlin Programming language which a user can use to store his/her monthly expenditure.

#Expenditure-Tracker An android app that allows the user to input , edit , view his/her expenditures for each month. Languages Used - Kotlin UI develo

It is a project that contains lessons and examples about Kotlin programming language. 🇰
It is a project that contains lessons and examples about Kotlin programming language. 🇰

Kotlin Tutorials What is Kotlin? I added the platforms it supports and great resources. You can access the article from the link below: https://medium

A multi-modular Gradle project that encapsulates various modules to learn Kotlin language, tools and frameworks.

KotlinLearn This is a gradle project for the sole basis of exploring and learning Kotlin language, tools and frameworks. The root project wil encapsul

Solutions to advent of code 2021 in the gen-Z programming language known as kotlin

Advent Of Code 2021 - Kotlin Edition How to run? Get the kotlin SDK using the sdkman tool: https://sdkman.io/sdks#kotlin Run the commands: ./gradlew

Owner
Samuel Owino
The Mandalorian
Samuel Owino
Vaibhav Jaiswal 57 Jan 3, 2023
Juara Android - Repository Google Code Lab, JuaraAndroid Event

Juara Android - Repository Google Code Lab, JuaraAndroid Event

Caravan Codes 3 Aug 6, 2022
Non-decompiling Android vulnerability scanner (DC25 demo lab, CB17)

README trueseeing is a fast, accurate and resillient vulnerabilities scanner for Android apps. It operates on Android Packaging File (APK) and outputs

Monolith Works Inc. 0 Jan 14, 2022
This is Android Application Development Lab manual. Created referring to VTU syllabus 18CSMP68.

MOBILE APPLICATION DEVELOPMENT Subject Code : 18CSMP68 VTU 6th Semister Manual Android Lab Manual 18CSMP68 ( Color Print Version ) Android Lab Manual

Jaideep Poojary 15 Oct 21, 2022
Integration of ONNX with Kotlin JS - Deep Learning running in the browser

Integration of ONNX with Kotlin JS - Deep Learning running in the browser

londogard 5 Jul 22, 2022
Learning kotlin CRUD operation with SQLite

Students App Other useful features CRUD operation SQLite integration Google Material Design library Resource defaults colors.xml - colors for the enti

Raihan Nismara 5 Dec 2, 2022
Simple Android app during a coding night. Just Learning Firebase and Android

KUI-App Simple Android app during a coding night. Just Learning Firebase and Android What we learned: Some basics of Android Basic setup of Firebase:

Kibabii University Informatics Club (KUI) 7 Aug 28, 2022
An android client application for the awesome kanji learning website wanikani.com

End of Life This project has reached EOL status. It will no longer be updated, patched, or supported. If you are interested in continuing the work, fe

İhsan Işık 507 Nov 12, 2022
Learning RxJava for Android by example

Learning RxJava for Android by example This is a repository with real-world useful examples of using RxJava with Android. It usually will be in a cons

Kaushik Gopal 7.6k Jan 5, 2023
A Wikipedia Android app built for learning purposes

A Wikipedia Android app built for learning purposes. This app uses Wikipedia API to fetch the relevant data about the searched query. It shows search suggestions as the user types the query to be searched, saves the visited searched pages in the history section using the Room database, shows a list of fetched data about the searched item, and lets the user visit its Wikipedia page if a user clicks on it.

Udit Bhaskar 7 Sep 7, 2022