Kotlin Program to Reverse a String

In this Kotlin tutorial, we will see three different ways to reverse a string.

Input String: I am Kotlin Programmer

Output String: remmargorP niltoK ma I

Let’s see each method one by one with program examples.

Method 1: Manually Traversing Each Character

In this method, we will manually traverse string characters from the end inside a loop and save them in a temporary variable.

fun main() {
    val s = "I am Kotlin Programmer"
    println("Input String: $s")
    var temp = ""
    var last = s.length - 1
    while (last >= 0) {
        temp += s[last]
    println("Reversed String: $temp")


Input String: I am Kotlin Programmer
Reversed String: remmargorP niltoK ma I

Method 2: Using Recursion

In this method, we will recursively call a function that reverses the string.

fun main() {
    val s = "I am Kotlin Programmer"
    println("Input String: $s")
    var temp = reverseString(s)
    println("Reversed String: $temp")

fun reverseString(s: String): String {
    if (s.isEmpty())
        return s

    return reverseString(s.substring(1)) + s[0]

Method 3: Using reversed() Function

In this method, we will use an inbuilt function reversed(). Let’s see how this works.

fun main() {
    val s = "I am Kotlin Programmer"
    println("Input String: $s")
    var temp = s.reversed()
    println("Reversed String: $temp")

Now you have learned various ways to reverse a string in Kotlin. If you have any queries, feel free to ask in the comment section below.

5 Best Kotlin Blogs 2022

Kotlin is a programming language made by Jetbrains that mainly runs on the Java Virtual Machine or JVM. Google in 2017 declared that Kotlin will become an official programming language that can be used on various Android platforms. It means that Kotlin can become the best programming language very soon. But, there are many people who want to brush up on their Kotlin skills and are looking for the right resources where they can improve their Kotlin knowledge.

Read more

7 Best IDEs for Kotlin in 2022

Android mobile application development is a growing industry with new mobile apps coming almost daily. It was the time when we did not have many options but code the application right from the scratch for each platform. But, wow with the constant innovation in the technology, we may easily code our own mobile apps quickly and efficiently by using various functions in it.

Kotlin today has become quite an emerging and prevalent language at a contemporary time. The language was released in 2011 and is rising till today. This is the cross-platform and general-purpose modern programming language. Kotlin programming language can be used for android app development. However, before you start using the Kotlin language, it is important to select an IDE where you can write its source code. Here, we will try to reveal some Best IDEs names by which you may understand which is the best IDE for Kotlin.

Which IDE is good for Kotlin and how do you find the right one? There are many editors and IDEs available today that is good for Kotlin programming, but some popular names I recommend include:

  • IntelliJ IDEA
  • Eclipse
  • Android Studio
  • Atom
  • Sublime Text
  • Vim
  • Visual Studio Code

But, before understanding each IDEs in detail, let us know more about them first.

What’s an IDE?

Integrated Development Environment or IDE is the comprehensive solution, which allows the mobile application developers to carry out the software development cycle at a faster pace. The development cycle includes writing, designing, testing, compiling, and debugging a code. For the fast development, it is suggested that you use IDE’s.

7 Best IDEs for Kotlin

1. IntelliJ IDEA

Having an exquisite and clean interface, this IDE specializes in enterprise web & mobile application development with help of Scala, Java, Groovy, Kotlin, and different frameworks for Android app development. Furthermore, detailed documentation will help in the seamless integration that is simple to understand.

Furthermore, multiple plugins are accessible for the IntelliJ IDEA to carry out any task. This framework-based assistance, unobtrusive intelligence, productivity boosters, inspections, and duplicates are offered with the IDE. By using IntelliJ IDE, you may do in-depth Kotlin coding, fast navigation as well as error analysis too.

Community edition in IntelliJ IDEA can easily be accessed free for developing Android and JVM app development, however, in its Ultimate Edition, you can access at the cost for applications.

  • Programming languages supported: Scala, Java, Kotlin, Groovy, TypeScript, JavaScript, and SQL.
  • Runs on: Linux, Windows, and macOS.


  • The editor offers in-depth coding.
  • With help of IntelliJ IDE, you can fast navigate any code.
  • Suppose you have some errors in the code then IDE can bring errors you have performed in the code.
  • It smartly compiles the source code.

2. Eclipse

As per PYPL Index, Eclipse is an open-source IDE and is the second most popular IDE used, and Eclipse Foundation says their current version is downloaded over 1.8 million times. This IDE started as the Java IDE and has grown to support several programming languages. 

For many years, the Eclipse version with an Android plug-in was one highly recommended development for various Android platforms. Even though Google has ceased their support for ADT, several mobile app developers continue using Eclipse for creating Android applications. This IDE comes in various versions, which includes many tailored for Java EE, Java, C/C++ & PHP.

  • Programming languages supported: C, C++, C#, Java, JavaScript, Cobol, PHP, Perl, R, Ruby, Python, and more.
  • Runs on: System supporting Java, Windows, Linux and macOS.


  • Support for various languages & operating systems
  • Huge customization options 
  • Big plug-ins marketplace
  • Integration with Maven, Git, and popular development tools
  • Big community & user base

3. Android Studio

This is the only mobile development suite you can find on this list! Android Studio offers web developers the fast tools to build applications on every Android device possible. Android Studio IDE has had complete support for Kotlin, with their support for the standard components & Android templates too.

As there’re huge design similarities between the Android Studio & IntelliJ IDEA, this makes it simple for the developers to create mobile apps with such IDE. They’re out of box tools include search tools and code refactoring to seek out or find performance issues and version incompatibilities. One can do editing with their Drag-and-Drop feature, whereas Gradle looks after automatic assembly & generation of .apk. Programmers and developers can view layouts on various mobile screens so that they may control differing resolutions and sizes.

  • Programming languages supported: C, C++, Java, Kotlin.
  • Runs on: Windows, Linux and macOS


  • Android Studio is quite helpful to run apps instantly.
  • It includes a fast emulator that is useful for running any applications much faster.
  • Has intelligent code editor.
  • Remarkably helpful in developing applications for various devices.
  • Allows you to connect with firebase.

4. Atom

Atom is the free & open-source editor for Linux, macOS, and Windows. This is highly preferred by a lot of developers for the clean interface, design, and excellent ecosystem of the community-built packages.

This IDE is primarily used for web development and is created by GitHub founder Chris Wanstrath. This is 100% free & open-source IDE and can be used for Linux, Windows, and macOS. This is customizable and has several useful plugins too. The primary benefit of Atom is it has an attractive interface, colour-coded syntax and more. But one disadvantage is it suffers from the start-up time.

  • Programming languages supported: JavaScript and TypeScript, C#, Java, Flow, and PHP.
  • Runs on: Linux, macOS, and Windows.


  • Syntax checking
  • Autocomplete is included in their IDE packages.
  • Move the cursor to variable and highlight references of the variable.
  • Find references that show you references of the class and variable.

5. Sublime Text

Sublime text editor IDE has become a popular Integrated development environment (IDE) in modern times. There’re a lot of advanced functions that are added within the editor and the editors are very useful for developers and programmers.

This is the cross-platform & open-source IDE that you can use for many languages. Moreover, common markup languages support the editor. The IDE was written in Python and C++ programming languages and was developed by Sublime HQ in 2008.

  • Programming languages supported: C++ & Python.
  • Runs on: macOS, Linux, and Windows


  • The text editor provides auto-completion.
  • Within the editor, you may jump your cursor and go anywhere.
  • Select multiple codes, words, or columns.

6. Vim

Vim is a configurable text editor made for creating or changing any type of text efficiently. Support of Kotlin can easily be added to Vim just by using Kotlin Plugin. Vim IDE is made with help of the C programming language. This is considered as an improved version of the VI code editor & is recommended for Unix systems.

Without any doubt, Vim is the oldest editor on the list around 26 years old. Though it may be simple to get totally lost in Vim, certainly there is one reason why this IDE has remained quite popular as various technologies come and go. 

The ubiquitous option is configurable and makes it simple for the developers and programmers to adapt to any problem, which comes in their way. It’s quite valuable for programmers and thus it is known as the programmer’s editor.

  • Programming languages supported: Perl and Python.
  • Runs on: Windows, Linux, and macOS


  • Command-centric editor
  • Many plugins available in this IDE and beneficial for programmers
  • Supportive on multiple windows
  • Supports multiple buffers

7. Visual Studio Code

Visual Studio Code is a prominent editor & IDE for developers and programmers. Most of the programmers make use of this editor to create codes. This is an open-source editor that you can use easily and was made by Microsoft. 

Visual Studio Code IDE was released in 2015 and was written with help of the javascript, HTML, typescript & CSS language.

  • Programming language supported: C++, C#, HTML, Java, JavaScript PHP, Python, TypeScript and more.
  • Runs on: Windows, macOS, Linux.


  • It is the fast source code.
  • Supports hundreds of languages.
  • Provides you features like bracket matching and syntax highlighting.
  • Box selection snippet comes embedded.

Final Words

Each of the IDE mentioned in this post comes with its unique benefits, which probably suit the demands of different users. Thus, some developers might suggest other tools that are based on the requirements and experience. But, developers’ experience & research recommend these are the top IDEs available right now in the market.

However, as use of the Android applications continues to increase, new platforms are going to emerge very soon. And, we should be ready for such changes.

Kotlin Program to Swap Two Numbers

Here you will learn different ways to swap values of two numbers.

Let’s say our two numbers are a=10 and b=20. So after swapping the values should be a=20 and b=10.

Now we will see how we can implement this in kotlin. We can do this in two ways, with and without using a temp variable.

Method 1: Swap Two Numbers Using Temporary Variable

fun main(args: Array<String>) {

    var a = 10
    var b = 20

    println("Values before swapping\na=$a b=$b")

    var temp = a
    a = b
    b = temp
    println("\nValues after swapping\na=$a \nb=$b")


Values before swapping
a=10 b=20

Values after swapping

Method 2: Swap Two Numbers Without Temporary Variable

fun main(args: Array<String>) {

    var a = 10
    var b = 20

    println("Values before swapping\na=$a b=$b")

    a = a+b
    b = a-b
    a = a-b
    println("\nValues after swapping\na=$a \nb=$b")

Let’s understand how it works. After a = a+b, a holds 30. Then after b = a-b, b holds 10. And finally, after a = a-b, a holds 20.

Comment down below if you have any queries regarding the swapping of two numbers in kotlin.

9 Best Kotlin Books in 2022

Master Android application development course with Kotlin, it is the modern programming language, which allows app developers to be productive and concise. Professionals can build apps for the mobile platform by using Kotlin and Android Studio.

Before delving more into this subject, it is important to know everything about Kotlin. Kotlin is the statically typed programming language for general-purpose, created by JetBrains and an official language to develop android apps. Kotlin is a highly preferred language for native Android application development. It’s cross-platform, modern, and simple to learn.

These days, Kotlin is used widely for Android development as it is concise, safe, and lots of fun to read & write. In this blog, we will guide beginners and pros to understand everything about Kotlin. The best way to learn is through books that will give the right information and knowledge to learn your first programming language. Let us go ahead and check out the top hand-chosen Kotlin books.

List of Best Kotlin Books in 2022

1. Kotlin in Action

Kotlin in Action

If you’re a professional Java developer searching for the Kotlin book, then this is the best book you can find on shelves. It teaches you to write idiomatic and clean code and how Java and Kotlin work together. This is written by the JetBrains core Kotlin java developers Jemerov and Isakova.

The book is further divided into two parts. In the first part, you will learn how to start using Kotlin with current libraries & APIs. In the second part, you learn to create APIs & abstractions in Kotlin. This covers some of the language’s highly important features.

It is one amazing book, you will learn the basics of Kotlin language, learn functional programming of JVM, and various concepts such as an object, interface, and lambda. When you go deeper into it, you can get some exciting concepts like operator overloading, DSL construction, higher-order, and much more. Once you finish, you can build the production-quality apps by using Kotlin.

buy now

2. Kotlin Programming: The Big Nerd Ranch Guide

Kotlin Programming: The Big Nerd Ranch Guide

Kotlin Programming is the companion guide of the Kotlin Essentials course. This book is mainly geared towards beginners and professional developers. You will start with the core principles such as conditionals, data types, and collections.

Based on the Big Nerd Ranch’s famous Kotlin Essentials course, the book tells you how you will work effectively with Kotlin language through examples and some clear explanations of Kotlin concepts & foundational APIs. This book introduces you to the JetBrains’ IntelliJ IDEA environment.

Once you complete the book, you will learn to create concise and reliable apps in Kotlin. Doesn’t matter if you have any prior knowledge of any programming language or not, the book can guide you from the first laws to the advanced use of Kotlin language.

buy now

3. How to Build Android Apps with Kotlin

How to Build Android Apps with Kotlin

If you are keen to start building Android 11 applications but do not know where you must start? Then How to Build Android Apps with Kotlin makes a perfect guide to help you kick-start the Android development practice.

The book begins with the fundamentals of application development, allowing you to use Android Studio & Kotlin to start building various Android projects. You will learn to create various applications and run them on virtual devices by guided exercises. Progressing through various chapters, you will get delved into Android’s RecyclerView and make most of the images, lists, and maps, or see how you can fetch the data from web service.

You will get to work on realistic projects, which are split up into bitesize exercises or activities, letting you challenge yourself in an attainable and enjoyable way. You can build applications for creating quizzes, read articles, store recipes, check weather reports, retrieve information, and also remind you about where you have parked the car.

buy now

4. Kotlin Cookbook: A Problem-Focused Approach

Kotlin Cookbook: A Problem-Focused Approach

Kotlin Cookbook 1st Edition is for both experienced and newbies programmers. Rather than teaching the basic syntax, in this book, you will learn Kotlin language by the personal use cases. In this book, you will learn how you can apply the Kotlin language to your projects.

An overall focus of this book is not just to teach you the Kotlin syntax or semantics but to show you why and when certain features must be utilized. The goal is not essential to cover each detail of Kotlin’s libraries and syntax. In an end, many recipes on the basic principles were also added to make this book understandable to the readers with just the beginning Kotlin knowledge level.

Practising with examples is very helpful for a learner as this can prepare you for real-time problems. The book does that perfectly. The book is filled with plenty of tips and tricks on various topics such as Kotlin basics, fundamental Kotlin features, collections and arrays, similarities with java programming, and much more.

buy now

5. Head First Kotlin

Head First Kotlin

Head First Kotlin 1st Edition is for java developers without any prior Kotlin programming experience. However, you must have a little background in the scripting language. The book takes a hands-on approach when it comes to learning Kotlin as well as teaches you to think like the Kotlin developer. This book covers everything from the Kotlin fundamentals to the higher-order functions.

It is the best book for beginners who are into learning Kotlin. This has the complete introduction to coding in the Kotlin language. This book teaches you each concept by using pictures and diagrams in complete detail. Thus, using the visually rich format.

The beginning goes from language fundamentals and concepts like generics, collections, lambda, and the higher-order functions. This teaches you about object-oriented java programming. When you complete this book, you will have developed the strong root of your favourite Kotlin language.

buy now

6. Android Studio 4.2 Development Essentials

Android Studio 4.2 Development Essentials

Android Studio 4.2 is for developers with programming experience and interested in Android development by using Kotlin. Looking at the huge 96 chapters, it is not for casual learners. Instead, it is for the readers who are very serious about Android development.

The book starts by outlining steps essential to set up the Android development as well as the testing environment and it introduces Kotlin programming, by addressing different data types, functions, flow control, lambdas, as well as object-oriented programming. This includes a complete overview of the Android Studio, covering various areas like tool windows, code editor, and Layout Editor tool. Introduction to the Android architecture will be followed by a complete explanation of the design of the Android apps and user interfaces by using the Android Studio environment.

In this book, you will learn to set up your Android development as well as a testing environment. After that, you will get a bit familiar with the Android Architecture Components like view models & app navigation. For getting the most from the book, you must have previous programming language experience. You must download Android Studio & Android SDK for the course. Ensure you have access to Mac, Windows, and Linux systems and creative applications ideas for development.

buy now

7. Beginning Android Development With Kotlin

Beginning Android Development With Kotlin

Beginning Android Development with Kotlin is yet another amazing book to learn Kotlin. In this book, you will learn how to build your Android applications right from beginning to end in minutes. You will find that in this book every section is perfectly written in a bite-sized way and on point as the author does not want you to waste time on content that you do not need. In an end, you will get to learn different skills that will help you create the app and submit this to an app store.

The primary goal of Beginning Android Development by Greg is to teach you Android development in an effective and manageable way without overpowering you. The main focus is on essentials and covers material in the hands-on practice to code in the right way.

buy now

8. The Joy of Kotlin

The Joy of Kotlin

Are you looking to learn to write right, simple-to-maintain and safe programs with Kotlin? Then The Joy of Kotlin is the best book for you. It explains in detail how you can build maintainable and bug-free apps. This book also explains ways to approach the common programming issues with the fresh and FP-inspired approach that are given by the seasoned engineer named Pierre-Yves Saumont. The book covers a complete Kotlin overview, memoization, recursion, and more.

The book teaches various concepts by using plenty of examples. Firstly, you will; learn about Kotlin programming with great functions. After that, this book touches to deal with various optional data, secure handling of any errors as well as handling the state mutation.

When you work through many examples, you will dive deep in handling errors as well as data rightly and taking benefit of laziness. The author’s great examples and insights can make you the better — and more joyful — developer!

buy now

9. Kotlin and Android Development featuring Jetpack

Kotlin and Android Development featuring Jetpack

The book is planned both for the new developers and anybody experienced with Android or Kotlin. This is one amazing book for beginners without any Kotlin and Android Experience. This helps the users to create their Android projects by using the Kotlin programming language in Android.

The guide helps the users to set up each tool that they will need for this process, which includes Android SDK & device emulator. The emulator is used later in this book to test apps that you have built, hence allowing you to visualize what the successful creation appears.

buy now

Final Thoughts

Kotlin is a useful, open-source, free, statically created “logical” language that was first intended for Java Virtual Machine or JVM and Android, which joins the object-oriented & practical programming features.

It’s centered on interoperability, lucidity, security, and tooling support. Hence, for other person doing Android development, the upsides of Kotlin is quite convincing. Time taken for the Java developer to learn the Kotlin language is some hours.

I hope this list of the best Kotlin books can make it easy and effortless for beginners and even experienced developers to learn the Kotlin language in the right way. We truly hope you have found this useful to learn a new language!

How to Convert Kotlin Code to Java Code?

Kotlin is a language that is well known for the interoperability with the java language. Kotlin is good for Mobile-cross platform, Native, Data-Science, Server-side, Web-development, Android. Interoperability is possible in both the languages because of the JVM (Java Virtual Machine) or in other words we can say that they are compiled to the same bytecode.

Read more

Kotlin List Interface

Before we jump onto List in Kotlin. Let’s just have a look at what java has to offer us in terms of the list. Java List helps us to maintain the ordered collection.

It has the index-based methods to insert, update, delete, and search all the elements in a list. In the java list, we can also store the null elements. The List Interface is found in the java.util package and inherits the collection interface. We can iterate the list in the forward or backward directions.

Read more

Kotlin Map Interface

Before we switch what Kotlin has to offer us in terms of Map Interface. Let us first recap the Map Interface with the java.

The map interface is present in java.util package which presents a mapping between the Key, Value.

Read more