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

Kotlin forEach Loop

Before we jump on for each that is our topic let’s first discuss the for each loop in java.

For each loop in Java would like to be:

class For_Each  	
{
    public static void main(String[] arg)
    {
        {
            int[] marks = { 12, 32, 97, 126, 130 };
              
            int highest_marks = maximum(marks);
            System.out.println("The highest score is " + highest_marks);
        }
    }
    public static int maximum(int[] numbers)
    { 
        int maxSoFar = numbers[0];
          
        // for each loop
        for (int num : numbers) 
        {
            if (num > maxSoFar)
            {
                maxSoFar = num;
            }
        }
    return maxSoFar;
    }
}

Output:

Read more

Will Kotlin Replace Python for Data Science?

With the trends rising forever and with Kotlin Replacing Scala to be the Second Most Used Language on JVM. There’s a lot of scope which this language have on us and for years to come. With Data Science and Machine Learning being Buzz word in the industry the next obvious question will be?

Read more

Kotlin Int to String

Having converted Kotlin Int to String, we will now explore the cases when we wish to convert an Int to a String. It usually happens when we wish to append an integer into a String.

The conversion from Kotlin Int to String can happen automatically when passes inside a print statement like below:

Read more

Kotlin String to Int

In modern languages, where the entire a lot of data is fetched to and from the applications. Every I/O is majorly worked in Strings. But the problems with String is their usability. I cant find the sum of two Strings until and unless you wish to view a concatenated value.

Read more

Kotlin String

String form a very important part in terms of input and output. All the input and output processing (including file I/O, Stream I/O) for kotlin as similar to Java is done in the form of Strings. Now let’s recall the Java’s main function.

public static void main(String [] args){	
	//Here, if you refer args or run time arguments are again taken in the form of Strings.
}

Read more

Kotlin Sealed Classes

Having gone through the concepts of classes in Kotlin, we understand that classes form the basis for any OOP’s oriented language and Kotlin is no different. As evident from the name itself, Sealed Classes are the classes which are closed or sealed, which makes their usage restricted.

Read more