We may earn an affiliate commission when you visit our partners.
Course image
Udemy logo

Kotlin for Beginners

Learn Programming With Kotlin

Peter Sommerhoff

>> This is the only Udemy course that is referenced from the official Kotlin website as well as the official Android developers website for people who want to learn Kotlin, whether for Android or other purposes.

Read more

>> This is the only Udemy course that is referenced from the official Kotlin website as well as the official Android developers website for people who want to learn Kotlin, whether for Android or other purposes.

>> Learn programming in Kotlin, the most beautiful modern programming language based on Java.

>> Join this beginner-friendly course to learn to write code with an awesome and easy-to-learn language.

>> Expand your expertise as a Java or Android Developer and improve the quality of your code.

>> I'll answer every question you have, help you personally if you get stuck and listen to your feedback. Join 15,000+ happy students of mine on Udemy.

This course will teach you programming in Kotlin. We begin with the basics so this course is completely suitable for beginners. You will put what you learn into practice in several coding challenges. So at the end, you'll be able to create your own applications in Kotlin.

If you're an Android developer, you can use this course to get up to speed with this awesome language. Kotlin will allow you to maintain a cleaner and more expressive code base, use concepts that go beyond even Java 8, and write more robust apps for Android.

Topics covered include:

  • Variables & nullable types (null safety)

  • Conditionals: if and when

  • Loops: for and while

  • Functions

  • Object orientation: classes, objects, interfaces, inheritance etc.

  • Data classes (a handy feature in Kotlin)

  • UPDATE: more object-orientation + binary and hexadecimal numbers

  • UPDATE: the information hiding principle + generics

This course also covers object-orientation, the major development paradigm you need to grasp in today's world. But we will also look at functional programming concepts that will make your life much easier.

Once you understand these, you will also be able to understand other object-oriented languages, including Java, PHP, C++, C#, Scala, or Swift. They all use this same basic paradigms.

So get in now to help shape this course and become part of the community inside.

Enroll now

What's inside

Learning objectives

  • Create professional applications using kotlin, the new java-based programming language developed by jetbrains
  • Understand the concepts of the kotlin language and how it integrates neatly with java
  • Understand the basics of object-oriented software development, the most important development paradigm
  • Understand the principles behind other object-oriented languages like java, c++, php, c#, scala, or swift
  • Use intellij, the popular java (and kotlin) ide, to write code effectively and professionally
  • Read code and write your kotlin code as well

Syllabus

Have an overview of the course

What YOU will create while following along this course, starting out with a simple "Hello World" program and creating more sophisticated programs over time.

After the course, you'll have all the fundamentals you need to start diving into other programming languages and learn more advanced concepts. The course will also be extended over time to cover more such advanced topics.

This course will start with the basics and cover conditional statements, functions, lists and arrays, classes and objects, inheritance and more about object-orientation. We will also learn some functional programming examples.

Read more

Udemy interface: Please make sure you are watching in HD! Also set your playback speed according to your preferences, that's a really useful feature. For questions, check out the discussions.

Following along: Take all the quizzes! They only take a few minutes and recap the most important points. Rock it in the discussions(!) so that I can help you when you get stuck and improve this course. Code along in every lesson, bring your own projects to life, and make it to the end!

Grasp the concepts of Kotlin and where it comes from

Kotlin is an object-oriented languages with functional features as well. It facilitates many things, provides null safety and offers a concise and readable syntax.

On try.kotlinlang.org (check link in the resources), you can try out some sample applications and get to know the basics of Kotlin. It is a great playground for simple code snippets.

How to setup the necessary environments and tools

This lectures guides you through the process of downloading the latest Java Development Kit (JDK) we need to use Kotlin.

In this step, we download the free and powerful IntelliJ Community Edition from the Jetbrains website. This is an Integrated Development Environment (IDE) that provides awesome support for Kotlin, Java, and many other languages. It is also the IDE used by Google for Android App Development.

Learn how to adjust the editor theme and font size in IntelliJ to your personal preferences and how to create the first project.

How to create a simple Kotlin program, how to use variables, using val vs. var, how to use the main() function, printing using println(), how to run a Kotlin program, basic types

In this lecture, we use Kotlin interactively in the REPL (read-eval-print-loop) as a calculator, learn how to assign values and run some simple commands.

This lecture covers how to create variables in Kotlin, when to use val vs. var and why you prefer val over var when creating variables to enforce immutability.

Variables

This lecture covers all basic types available in Kotlin plus strings to store text.

Basic types in Kotlin include Byte, Short, Int, Long, Float, Double, Boolean, and Char. This lecture guides you through each of them and their differences.

Variables and Data Types

Expressions are pieces of code that have a value, such as 4*(3+5) or listOf(1,2,3,4,5). We can assign the values of expressions to variables and the Kotlin REPL will print an expression's value right below it whenever we type in an expression.

Statements on the other hand don't carry a value, such as print("Hello there") or val a = 4. Assignments are a special type of statements because they also don't have a value.

Check your understanding of the differences between expressions and statements.

In contrast to languages like Java, Kotlin offers null safety through explicit nullable types!

Learn how to create nullable variables and why you should avoid this. You will also understand the advantages of having to make variables explicitly nullable to avoid NullPointerExceptions.

Nullables

Now it's time to create our very first stand-alone Kotlin application!

You will create a simple "Hello World" app and be guided through the process of creating a main() function as the entry point to your application.

If and when statements, if / when statements vs. expressions

Learn how to use if statements for handling conditional program flow. So this concept lets you define different program behavior based on conditions you can define.

if Statements

This lecture covers the use of when statements to handle a fixed set of possible options.

In contrast to if statements, these do not allow arbitrary conditions and are commonly used to switch between a number of distinct cases based on the value of a variable.

when Statements

Learn when to use if statements vs. when statements.

If statements allow defining arbitrary conditions and are the most common choice to handle control flow. In some cases however, when statements express your intentions better. That is, when you want to switch application behavior based on some distinct values of a variable.

When statements can always be simulated by if statements.

Conditional Statements Using "if" and "when"

In Kotlin, we can use conditional statements as expressions with a value. In fact, every if or when statement is an expression in Kotlin and we can, for example, save its value into a variable.

The last expression in each block of an if or when expression defines the value of the whole if or when expression if that block is executed.

Inside when blocks, we can actually use more sophisticated expressions on the left side than just plain values. More specifically, Kotlin allows us to check for ranges, types, values of function calls and more on the left side of each condition in when constructs.

Advanced Conditionals

Coding Challenge: Put your knowledge of conditionals into practice by generating random numbers and checking which range they fall into.

Creating, initializing, accessing, and using arrays and lists in Kotlin, how to handle collections like these.

Learn about two super important data types of every programming languages: Arrays & Lists!

What are arrays? What are lists? This lecture goes through each of them and explains their differences and similarities. You will also learn when to use arrays vs. lists which is a question you find many people asking online.

Learn how to create, modify, and access arrays in Kotlin using the square bracket notation. This allows you to store multiple elements inside a single variable.

Later, we will also see how to loop over arrays to perform some tasks on each of its elements.

This lecture guides you through the process of creating, modifying, and accessing lists in Kotlin. We will see that we can work with lists in a similar way as we do with arrays, but that there are also some differences to keep in mind.

Arrays and Lists in Kotlin
Using for-loops, using while- and do-while-loops, using return/break/continue, labeling loops, looping over arrays and lists, iterators

Learn how to use for loops in Kotlin to loop over an array/list or to repeat a certain block of code a certain number of time (when you know in advance how many iterations you will need).

Learn how to use while loops in Kotlin to repeat blocks of code, similar to for loops. But when using while loops, you don't need to know the number of iterations in advance. The while loop allows you to define arbitrary conditions which must be true for the loop to continue.

Loops Using "for" and "while"

The break and continue statements allow you to completely skip over a loop or to skip to the next iteration, respectively. So with break, you can stop a loop and go on with execution right after it. Whereas with continue, you can skip to the next iteration of a loop to avoid unnecessary computation.

The break statement is useful, for example, when you are only interested in the first occurance of something. For instance, to check if an array contains a certain value, you just need to check until you find it. After finding that first occurance, you can skip the rest of the loop.

The continue statement is useful to skip computations in unnecessary iterations. For example, if you only want to do something with String of length > 2, you can skip iterations with a shorter string when you iterate over a list of strings.

Learn how to use loop labels and then address them in break and continue statements. This allows you to break or continue an outer loop when inside a nested loop.

Using break, continue and return

What's the sum of all numbers from 100 to 100,000?

You are now a novice programmer in Kotlin! Congratulations, keep going forward and I'll see you again as an apprentice!

Congratulations! By making it this far, you are already ahead of 90% of the other students. Keep going!

Recap of all topics covered so far, including variables, data types, nullable types, conditionals, arrays, lists, and loops.

Another programming task for you to practice what you learned.

Keep going! The best topics are still to come!

Functions

This lecture teaches you one of the most important concepts that applies not only to Kotlin but all other programming languages as well: creating and using functions!

Functions are self-contained pieces of code that can take in parameters and may return a value. Parameters allow passing in information into the function when calling it, so that the function can then work with that data and perform computations on it.

Let's see how to reverse a list using a loop. This is a functionality that often comes in handy when working with ordered collections like lists and arrays.

This code along gives you some more intuition on how to work with loops if you've never worked with them before. It also helps you internalize how to write loops in Kotlin. And of course, it's guides you into what a programmer does all day: implementing algorithms. Reversing an ordered collection is great little algorithm to start with.

Know the basics of object-orientation, difference between classes and objects, properties and methods, interfaces and inheritance

Object-orientation is the most widely used software development paradigm. Popular programming languages are mostly focused on object-oriented development, including Java, Python, C++, C#, PHP, and Swift.

This lecture explains all the major elements of object-orientation: classes, objects, interfaces, data, and methods. It also goes through the concept of creating an abstraction of the real world by modeling objects.

The Basics of Object-Orientation

Let's create our first class in Kotlin!

This lectures guides you through creating basic classes, adding properties to classes, creating objects from it and accessing its properties. Classes are like blueprints from which we can create objects and they contain properties and methods. The next lecture will cover methods.

While properties define what data a class holds, methods define functionality and can execute.

This lecture teaches you how to add methods to classes, which are essentially just functions inside a class. We can then call those methods on our class.

Properties and Methods

Learn how to define basic constructors in Kotlin to define how exactly objects are supposed to be created from a class. Parameters can be added to the constructor to add properties to the class and define what information/data an object needs to be instantiated.

Object Creation
Coding Challenge: Classes

This lecture covers how to use named parameters and default values for function and constructor calls. This is super handy to make the code more readable and also allows you to change to order of the parameters when calling the constructor or function.

Named Parameters & Default Values

Learn how and when to use open classes in Kotlin to allow inheritance. This also includes how to extend classes, implement interfaces, and how to override methods and properties

Open Classes and Inheritance

Learn how and when to use the "abstract" keyword in Kotlin, what exactly abstract classes are and when you should use them.

Abstract Classes

You can use the open keyword to allow inheriting from a class or overriding a property/method vs. the abstract keyword to require inheriting and overriding.

Open vs. Abstract

Interfaces are like contracts that classes may adhere to (meaning they implement that interface). This lecture explains...

  • how you can create interfaces,
  • what constraints there are in interfaces,
  • the importance of interfaces in object-oriented programming,
  • and the differences compared to classes.
Interfaces
Object-Orientation - Part I
Inheritance structures, overriding functions, open-closed principle, class properties, visibility modifiers

Learn how to handle overriding in Kotlin. This lecture covers some of the special cases that you may come across and the overriding rules involved. This includes required vs. optional overriding and handling name clashes from two supertypes

Overriding

Learn how to create data classes! This is a really handy feature in Kotlin that takes a lot of work from your shoulders.

Data classes automatically override methods such as toString() so that they can be printed to the console in a readable way. Learn about all the cool features of data classes in this lecture.

Data Classes

Put what you learned into practice by creating interfaces, abstract classes, and concrete classes for a sample library inventory system.

Singletons are classes of which at most one instance can exist at runtime.

In software design, you often come across classes for which you only need or want one object at runtime. Imagine for example a Cache class -- in many cases, you only want (at most) one cache object to exist.

This can even prevent errors resulting from working with another object than you wanted.

Enumerations, simply called enums, are a great way to design classes of which only a defined finite set of instances are possible. In this case, those possible instances are simply listed ("enumerated") explicitly in the code.

This also means that there can be no other objects of the enum class than these at runtime -- there is no constructor available.

Recap the basics of enum classes.

Packages are used to structure your code into logical units. Thereby, they also define boundaries between the classes in the different packages which can be exploited for information hiding (see later lectures).

Classes that perform similar tasks should be grouped into a package. Such classes from the same package may rely a lot on each other. However, classes from different packages should have less dependencies (e.g. calling a methods from classes from different packages).

Grouping classes into packages is an important sub-task of software design.

Recap of the basic concepts of packages.

Imports allow to make classes from other packages accessible inside your class.

Therefore, imports are what allow you to access decades of work, research, and knowledge from developers around the world by using, among many others, the Java and Kotlin standard libraries.

In Kotlin, you can import a whole package (non-recursive), classes, top-level functions, enum instances, and methods declared in objects.

Check what you learned about import statements!

Learn how numbers are represented as binary and hex values.
Hexadecimal Numbers & The Color Enum

Test what you learned about hex numbers!

Binary Numbers & The Color Enum

Strengthen your knowledge about the binary number system!

Bitwise Operators
Learn the essential principle of information hiding + how to use generics to avoid code duplication in Kotlin

Information hiding is a fundamental principle in object-oriented software design that increases the reusability, maintainability, and robustness of your code.

The basic idea is to restrict access to the internals of a class from the outside. That way, users of your class can also use it via a well-defined interface, meaning that you can enforce invariants in your code more effectively.

Information Hiding

In Kotlin, you declare properties as members of a class via val/var -- in contrast to Java, where fields are used.

With properties, there are implicit getters and setters that are called whenever the property is accessed or updated. This can greatly enhance maintainability and extensibility of the code.

Quiz: Getters and Setters

Visibilities are the way to implement information hiding in object-oriented languages like Kotlin, Java, Scala, Swift etc.

The visibility of a class, property or method defines from where it will be visible/accessible, including which kinds of other classes have access to that element.

Kotlin has the following visibility modifiers:

  1. private
  2. protected
  3. internal
  4. public (default)
Quiz: Visibilities

Generics are a more advanced concept of OO design which help you avoid code duplication for groups of similar classes, especially collection classes (such as Array, List, Map etc.)

In contrast to a non-generic class, a generic class is parametrized with one or more generic type parameters which can be defined when instantiating an object of the class. For example, Kotlin's built-in generic class Array<T> (read "array of T") can be instantiated as an Array<Int>, an Array<Person>, etc.

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Explores Kotlin, which is standard in Android App Development
Examines object-oriented software development, which is core to Java, PHP, C++, C#, Scala, or Swift
Taught by Peter Sommerhoff, who is an experienced coder and Kotlin trainer
Meets the basic learning needs of complete beginners interested in programming and Kotlin
Develops the foundational skills and knowledge for aspiring programmers
Builds a strong foundation for intermediate programmers who wish to improve their object-oriented programming skills
Takes a hands-on approach to teaching Kotlin fundamentals

Save this course

Save Kotlin for Beginners: Learn Programming With Kotlin to your list so you can find it easily later:
Save

Activities

Coming soon We're preparing activities for Kotlin for Beginners: Learn Programming With Kotlin. These are activities you can do either before, during, or after a course.

Career center

Learners who complete Kotlin for Beginners: Learn Programming With Kotlin will develop knowledge and skills that may be useful to these careers:
Computer Programmer
Computer Programmers write and test code that makes computers perform tasks. This course can help build the programming skills needed for this field. It covers variables, loops, arrays, functions, and object orientation, which are essential concepts for Computer Programmers to master.
Software Engineer
A Software Engineer designs, develops, and maintains software systems. This course can help build the strong programming foundations needed to excel in this field. The course covers variables, loops, arrays, functions, and object orientation, all of which are essential concepts for Software Engineers to master.
Mobile Application Developer
Mobile Application Developers build and maintain mobile apps for smartphones and tablets. This course can help build the programming skills needed for this field. It covers variables, loops, arrays, functions, and object orientation, which are essential concepts for Mobile Application Developers to master. Kotlin is a popular language for Android development, making this course even more relevant for those interested in this field.
Software Architect
Software Architects design and build software systems. This course can help build the strong programming foundations needed to excel in this field. The course covers variables, loops, arrays, functions, and object orientation, all of which are essential concepts for Software Architects to master.
Web Developer
Web Developers build and maintain websites and web applications. This course provides a solid foundation in the Kotlin programming language, which is increasingly used for web development. The course also covers concepts such as variables, loops, arrays, and functions, which are essential for Web Developers to understand.
Machine Learning Engineer
Machine Learning Engineers build and maintain machine learning models. This course provides a solid foundation in the Kotlin programming language, which is increasingly used for machine learning. The course also covers concepts such as variables, loops, arrays, and functions, which are essential for Machine Learning Engineers to understand.
Information Technology Specialist
Information Technology Specialists support and maintain computer systems. This course can help build the programming skills needed for this field. It covers variables, loops, arrays, functions, and object orientation, which are essential concepts for Information Technology Specialists to understand.
Database Administrator
Database Administrators maintain and manage databases. This course can help build the programming skills needed for this field. It covers variables, loops, arrays, functions, and object orientation, which are essential concepts for Database Administrators to understand.
Quality Assurance Analyst
Quality Assurance Analysts test and evaluate software products. This course can help build the programming skills needed for this field. It covers variables, loops, arrays, functions, and object orientation, which are essential concepts for Quality Assurance Analysts to understand.
Computer Systems Analyst
Computer Systems Analysts analyze and design computer systems. This course can help build the programming skills needed for this field. It covers variables, loops, arrays, functions, and object orientation, which are essential concepts for Computer Systems Analysts to understand.
Data Scientist
Data Scientists use data to solve business problems. This course can help build the programming skills needed for this field. It covers variables, loops, arrays, functions, and object orientation, which are essential concepts for Data Scientists to understand.
Computer Network Architect
Computer Network Architects design and build computer networks. This course may be useful for those interested in this field, as it provides a solid foundation in the Kotlin programming language. Kotlin is increasingly used for network programming, which is a subfield of computer network architecture.
Information Security Analyst
Information Security Analysts protect computer systems from security threats. This course may be useful for those interested in this field, as it provides a solid foundation in the Kotlin programming language. Kotlin is increasingly used for security programming, which is a subfield of information security.
Computer Hardware Engineer
Computer Hardware Engineers design and build computer hardware. This course may be useful for those interested in this field, as it provides a solid foundation in the Kotlin programming language. Kotlin is increasingly used for embedded systems programming, which is a subfield of computer hardware engineering.
Technical Writer
Technical Writers create documentation for technical products. This course may be useful for those interested in this field, as it provides a solid foundation in the Kotlin programming language. Kotlin is increasingly used for developing technical documentation, especially for software products.

Reading list

We've selected seven books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Kotlin for Beginners: Learn Programming With Kotlin.
Provides a comprehensive overview of the Kotlin programming language, covering everything from basic syntax to advanced topics like coroutines and functional programming. It valuable resource for both beginners and experienced Kotlin developers who want to learn more about the language.
Collection of practical recipes and solutions to common problems that Kotlin developers face. It valuable resource for Kotlin developers of all levels.
Practical guide to using Kotlin for Android development. It covers all the essential topics, from setting up your development environment to building and deploying Android apps with Kotlin.
Beginner-friendly introduction to Android development with Kotlin. It covers all the essential topics, from setting up your development environment to building and deploying Android apps with Kotlin.
Beginner-friendly introduction to the Kotlin programming language. It uses a conversational and accessible style to teach the basics of Kotlin, making it a good choice for those who are new to programming or to the Kotlin language.
Provides a comprehensive overview of Android development, covering all the essential topics from setting up your development environment to building and deploying Android apps. It good choice for those who are new to Android development or who want to learn more about the Kotlin programming language.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2024 OpenCourser