{"id":13458633,"url":"https://github.com/amitshekhariitbhu/from-java-to-kotlin","last_synced_at":"2026-03-10T07:03:41.986Z","repository":{"id":37458434,"uuid":"91953571","full_name":"amitshekhariitbhu/from-java-to-kotlin","owner":"amitshekhariitbhu","description":"From Java To Kotlin - Your Cheat Sheet For Java To Kotlin","archived":false,"fork":false,"pushed_at":"2025-07-18T11:33:29.000Z","size":265,"stargazers_count":6302,"open_issues_count":10,"forks_count":782,"subscribers_count":186,"default_branch":"master","last_synced_at":"2025-10-10T18:03:09.688Z","etag":null,"topics":["android","cheet-sheet","java","java-to-kotiln","kotlin","kotlin-android","kotlin-language"],"latest_commit_sha":null,"homepage":"https://outcomeschool.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amitshekhariitbhu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-21T11:56:27.000Z","updated_at":"2025-10-04T13:56:04.000Z","dependencies_parsed_at":"2024-12-02T01:17:51.057Z","dependency_job_id":null,"html_url":"https://github.com/amitshekhariitbhu/from-java-to-kotlin","commit_stats":null,"previous_names":["mindorksopensource/from-java-to-kotlin"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/amitshekhariitbhu/from-java-to-kotlin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2Ffrom-java-to-kotlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2Ffrom-java-to-kotlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2Ffrom-java-to-kotlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2Ffrom-java-to-kotlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amitshekhariitbhu","download_url":"https://codeload.github.com/amitshekhariitbhu/from-java-to-kotlin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2Ffrom-java-to-kotlin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30326893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","cheet-sheet","java","java-to-kotiln","kotlin","kotlin-android","kotlin-language"],"created_at":"2024-07-31T09:00:54.718Z","updated_at":"2026-03-10T07:03:41.971Z","avatar_url":"https://github.com/amitshekhariitbhu.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg alt=\"FromJavaToKotlin\" src=\"https://raw.githubusercontent.com/amitshekhariitbhu/from-java-to-kotlin/master/assets/from_java_to_kotlin.png\"\u003e\n\u003c/p\u003e\n\n# From Java To Kotlin\n\n\u003e From Java To Kotlin - Your Cheat Sheet For Java To Kotlin\n\n## About me\n\nHi, I am Amit Shekhar, Founder @ [Outcome School](https://outcomeschool.com) • IIT 2010-14 • I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.\n\n### Follow Amit Shekhar\n\n- [X/Twitter](https://twitter.com/amitiitbhu)\n- [LinkedIn](https://www.linkedin.com/in/amit-shekhar-iitbhu)\n- [GitHub](https://github.com/amitshekhariitbhu)\n\n### Follow Outcome School\n\n- [YouTube](https://youtube.com/@OutcomeSchool)\n- [X/Twitter](https://x.com/outcome_school)\n- [LinkedIn](https://www.linkedin.com/company/outcomeschool)\n- [GitHub](http://github.com/OutcomeSchool)\n\n## I teach at Outcome School\n\n- AI and Machine Learning\n- Android\n\nJoin Outcome School and get a high-paying tech job: [Outcome School](https://outcomeschool.com)\n\n## Live session on \"Android Developer Interview Preparation for Product-based Companies\"\n\nI conducted a live session on \"Android Developer Interview Preparation for Product-based Companies\"\n\nInteracted with over **500 Android Developers**.\n\nGuided, motivated, and inspired them to aim higher and achieve more.\n\n**Recording Link**: https://drive.google.com/file/d/1VWW3l_itH6vYbNYzNer6XW5_x0jzOF4O/view?usp=sharing\n\n**Document Link**: https://docs.google.com/document/d/14UdD7Gd1j3no583ALx2t2Ggt3G_CECYhenLE-m-bkzA/edit?usp=sharing\n\n## Print to Console\n\u003e Java\n\n```java\nSystem.out.print(\"Amit Shekhar\");\nSystem.out.println(\"Amit Shekhar\");\n```\n\n\u003e Kotlin\n\n```kotlin\nprint(\"Amit Shekhar\")\nprintln(\"Amit Shekhar\")\n```\n\n---\n## Constants and Variables\n\u003e Java\n\n```java\nString name = \"Amit Shekhar\";\nfinal String name = \"Amit Shekhar\";\n```\n\n\u003e Kotlin\n\n```kotlin\nvar name = \"Amit Shekhar\"\nval name = \"Amit Shekhar\"\n```\n\n---\n## Assigning the null value\n\u003e Java\n\n```java\nString otherName;\notherName = null;\n```\n\n\u003e Kotlin\n\n```kotlin\nvar otherName : String?\notherName = null\n```\n\n---\n## Verify if value is null\n\u003e Java\n\n```java\nif (text != null) {\n  int length = text.length();\n}\n```\n\n\u003e Kotlin\n\n```kotlin\ntext?.let {\n    val length = text.length\n}\n// or simply\nval length = text?.length\n```\n\n---\n## Verify if value is NotNull  OR NotEmpty\n\u003e Java\n```java\nString sampleString = \"Shekhar\";\nif (!sampleString.isEmpty()) {\n    myTextView.setText(sampleString);\n}\nif(sampleString!=null \u0026\u0026 !sampleString.isEmpty()){\n    myTextView.setText(sampleString); \n}\n```\n\u003e Kotlin\n\n```kotlin\nvar sampleString =\"Shekhar\"\nif(sampleString.isNotEmpty()){  //the feature of kotlin extension function\n    myTextView.text=sampleString\n}\nif(!sampleString.isNullOrEmpty()){\n   myTextView.text=sampleString \n}\n```\n---\n## Concatenation of strings\n\u003e Java\n\n```java\nString firstName = \"Amit\";\nString lastName = \"Shekhar\";\nString message = \"My name is: \" + firstName + \" \" + lastName;\n```\n\n\u003e Kotlin\n\n```kotlin\nvar firstName = \"Amit\"\nvar lastName = \"Shekhar\"\nvar message = \"My name is: $firstName $lastName\"\n```\n\n---\n## New line in string\n\u003e Java\n\n```java\nString text = \"First Line\\n\" +\n              \"Second Line\\n\" +\n              \"Third Line\";\n```\n\n\u003e Kotlin\n\n```kotlin\nval text = \"\"\"\n        |First Line\n        |Second Line\n        |Third Line\n        \"\"\".trimMargin()\n```\n\n---\n\n## Substring\n\u003e Java\n\n```java\nString str = \"Java to Kotlin Guide\";\nString substr = \"\";\n\n//print java\nsubstr = str.substring(0, 4);\nSystem.out.println(\"substring = \" + substr);\n\n//print kotlin\nsubstr = str.substring(8, 14);\nSystem.out.println(\"substring = \" + substr);\n```\n\n\u003e Kotlin\n\n```kotlin\nvar str = \"Java to Kotlin Guide\"\nvar substr = \"\"\n\n//print java\nsubstr = str.substring(0..3) //\nprintln(\"substring $substr\")\n\n//print kotlin\nsubstr = str.substring(8..13)\nprintln(\"substring $substr\")\n```\n\n---\n\n## Ternary Operations\n\u003e Java\n\n```java\nString text = x \u003e 5 ? \"x \u003e 5\" : \"x \u003c= 5\";\n\nString message = null;\nlog(message != null ? message : \"\");\n```\n\n\u003e Kotlin\n\n```kotlin\nval text = if (x \u003e 5) \"x \u003e 5\" else \"x \u003c= 5\"\n\nval message: String? = null\nlog(message ?: \"\")\n```\n\n---\n## Bitwise Operators\n\u003e Java\n\n```java\nfinal int andResult  = a \u0026 b;\nfinal int orResult   = a | b;\nfinal int xorResult  = a ^ b;\nfinal int rightShift = a \u003e\u003e 2;\nfinal int leftShift  = a \u003c\u003c 2;\nfinal int unsignedRightShift = a \u003e\u003e\u003e 2;\n```\n\n\u003e Kotlin\n\n```kotlin\nval andResult  = a and b\nval orResult   = a or b\nval xorResult  = a xor b\nval rightShift = a shr 2\nval leftShift  = a shl 2\nval unsignedRightShift = a ushr 2\n```\n\n---\n## Check the type and casting\n\u003e Java\n\n```java\nif (object instanceof Car) {\n  Car car = (Car) object;\n}\n```\n\n\u003e Kotlin\n\n```kotlin\nif (object is Car) {\nvar car = object as Car\n}\n\n// if object is null\nvar car = object as? Car // var car = object as Car?\n```\n\n---\n## Check the type and casting (implicit)\n\u003e Java\n\n```java\nif (object instanceof Car) {\n   Car car = (Car) object;\n}\n```\n\n\u003e Kotlin\n\n```kotlin\nif (object is Car) {\n   var car = object // smart casting\n}\n\n// if object is null\nif (object is Car?) {\n   var car = object // smart casting, car will be null\n}\n```\n\n---\n## Multiple conditions\n\u003e Java\n\n```java\nif (score \u003e= 0 \u0026\u0026 score \u003c= 300) { }\n```\n\n\u003e Kotlin\n\n```kotlin\nif (score in 0..300) { }\n```\n\n---\n## Multiple Conditions (Switch case)\n\u003e Java\n\n```java\nint score = // some score;\nString grade;\nswitch (score) {\n  case 10:\n  case 9:\n    grade = \"Excellent\";\n    break;\n  case 8:\n  case 7:\n  case 6:\n    grade = \"Good\";\n    break;\n  case 5:\n  case 4:\n    grade = \"OK\";\n    break;\n  case 3:\n  case 2:\n  case 1:\n    grade = \"Fail\";\n    break;\n  default:\n      grade = \"Fail\";       \n}\n```\n\n\u003e Kotlin\n\n```kotlin\nvar score = // some score\nvar grade = when (score) {\n  9, 10 -\u003e \"Excellent\"\n  in 6..8 -\u003e \"Good\"\n  4, 5 -\u003e \"OK\"\n  else -\u003e \"Fail\"\n}\n```\n\n---\n## For-loops\n\u003e Java\n\n```java\nfor (int i = 1; i \u003c= 10 ; i++) { }\n\nfor (int i = 1; i \u003c 10 ; i++) { }\n\nfor (int i = 10; i \u003e= 0 ; i--) { }\n\nfor (int i = 1; i \u003c= 10 ; i+=2) { }\n\nfor (int i = 10; i \u003e= 0 ; i-=2) { }\n\nfor (String item : collection) { }\n\nfor (Map.Entry\u003cString, String\u003e entry: map.entrySet()) { }\n```\n\n\u003e Kotlin\n\n```kotlin\nfor (i in 1..10) { }\n\nfor (i in 1 until 10) { }\n\nfor (i in 10 downTo 0) { }\n\nfor (i in 1..10 step 2) { }\n\nfor (i in 10 downTo 0 step 2) { }\n\nfor (item in collection) { }\n\nfor ((key, value) in map) { }\n```\n\n---\n## Collections\n\u003e Java\n\n```java\nfinal List\u003cInteger\u003e listOfNumber = Arrays.asList(1, 2, 3, 4);\n\nfinal Map\u003cInteger, String\u003e keyValue = new HashMap\u003cInteger, String\u003e();\nmap.put(1, \"Amit\");\nmap.put(2, \"Anand\");\nmap.put(3, \"Messi\");\n\n// Java 9\nfinal List\u003cInteger\u003e listOfNumber = List.of(1, 2, 3, 4);\n\nfinal Map\u003cInteger, String\u003e keyValue = Map.of(1, \"Amit\",\n                                             2, \"Anand\",\n                                             3, \"Messi\");\n```\n\n\u003e Kotlin\n\n```kotlin\nval listOfNumber = listOf(1, 2, 3, 4)\nval keyValue = mapOf(1 to \"Amit\",\n                     2 to \"Anand\",\n                     3 to \"Messi\")\n```\n\n---\n## for each\n\u003e Java\n\n```java\n// Java 7 and below\nfor (Car car : cars) {\n  System.out.println(car.speed);\n}\n\n// Java 8+\ncars.forEach(car -\u003e System.out.println(car.speed));\n\n// Java 7 and below\nfor (Car car : cars) {\n  if (car.speed \u003e 100) {\n    System.out.println(car.speed);\n  }\n}\n\n// Java 8+\ncars.stream().filter(car -\u003e car.speed \u003e 100).forEach(car -\u003e System.out.println(car.speed));\ncars.parallelStream().filter(car -\u003e car.speed \u003e 100).forEach(car -\u003e System.out.println(car.speed));\n```\n\n\u003e Kotlin\n\n```kotlin\ncars.forEach {\n    println(it.speed)\n}\n\ncars.filter { it.speed \u003e 100 }\n      .forEach { println(it.speed)}\n\n// kotlin 1.1+\ncars.stream().filter { it.speed \u003e 100 }.forEach { println(it.speed)}\ncars.parallelStream().filter { it.speed \u003e 100 }.forEach { println(it.speed)}\n```\n\n---\n## Splitting arrays\n\u003e java\n\n```java\nString[] splits = \"param=car\".split(\"=\");\nString param = splits[0];\nString value = splits[1];\n```\n\n\n\u003e kotlin\n\n```kotlin\nval (param, value) = \"param=car\".split(\"=\")\n```\n\n---\n## Defining methods\n\u003e Java\n\n```java\nvoid doSomething() {\n   // logic here\n}\n```\n\n\u003e Kotlin\n\n```kotlin\nfun doSomething() {\n   // logic here\n}\n```\n\n### Default values for method parameters\n\u003e Java\n\n```java\ndouble calculateCost(int quantity, double pricePerItem) {\n    return pricePerItem * quantity;\n}\n\ndouble calculateCost(int quantity) {\n    // default price is 20.5\n    return 20.5 * quantity;\n}\n```\n\n\u003e Kotlin\n\n```kotlin\nfun calculateCost(quantity: Int, pricePerItem: Double = 20.5) = quantity * pricePerItem\n\ncalculateCost(10, 25.0) // 250\ncalculateCost(10) // 205\n\n```\n\n---\n## Variable number of arguments\n\u003e Java\n\n```java\nvoid doSomething(int... numbers) {\n   // logic here\n}\n```\n\n\u003e Kotlin\n\n```kotlin\nfun doSomething(vararg numbers: Int) {\n   // logic here\n}\n```\n\n---\n## Defining methods with return\n\u003e Java\n\n```java\nint getScore() {\n   // logic here\n   return score;\n}\n```\n\n\u003e Kotlin\n\n```kotlin\nfun getScore(): Int {\n   // logic here\n   return score\n}\n\n// as a single-expression function\n\nfun getScore(): Int = score\n\n// even simpler (type will be determined automatically)\n\nfun getScore() = score // return-type is Int\n```\n\n---\n## Returning result of an operation\n\u003e Java\n\n```java\nint getScore(int value) {\n    // logic here\n    return 2 * value;\n}\n```\n\n\u003e Kotlin\n\n```kotlin\nfun getScore(value: Int): Int {\n   // logic here\n   return 2 * value\n}\n\n// as a single-expression function\nfun getScore(value: Int): Int = 2 * value\n\n// even simpler (type will be determined automatically)\n\nfun getScore(value: Int) = 2 * value // return-type is int\n```\n\n---\n## Constructors\n\u003e Java\n\n```java\npublic class Utils {\n\n    private Utils() {\n      // This utility class is not publicly instantiable\n    }\n\n    public static int getScore(int value) {\n        return 2 * value;\n    }\n\n}\n```\n\n\u003e Kotlin\n\n```kotlin\nclass Utils private constructor() {\n\n    companion object {\n\n        fun getScore(value: Int): Int {\n            return 2 * value\n        }\n\n    }\n}\n\n// another way\n\nobject Utils {\n\n    fun getScore(value: Int): Int {\n        return 2 * value\n    }\n\n}\n```\n\n---\n## Getters and Setters\n\u003e Java\n\n```java\npublic class Developer {\n\n    private String name;\n    private int age;\n\n    public Developer(String name, int age) {\n        this.name = name;\n        this.age = age;\n    }\n\n    public String getName() {\n        return name;\n    }\n\n    public void setName(String name) {\n        this.name = name;\n    }\n\n    public int getAge() {\n        return age;\n    }\n\n    public void setAge(int age) {\n        this.age = age;\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) return true;\n        if (o == null || getClass() != o.getClass()) return false;\n\n        Developer developer = (Developer) o;\n\n        if (age != developer.age) return false;\n        return name != null ? name.equals(developer.name) : developer.name == null;\n\n    }\n\n    @Override\n    public int hashCode() {\n        int result = name != null ? name.hashCode() : 0;\n        result = 31 * result + age;\n        return result;\n    }\n\n    @Override\n    public String toString() {\n        return \"Developer{\" +\n                \"name='\" + name + '\\'' +\n                \", age=\" + age +\n                '}';\n    }\n}\n```\n\n\u003e Kotlin\n\n```kotlin\ndata class Developer(var name: String, var age: Int)\n\n```\n\n---\n## Cloning or copying\n\u003e Java\n\n```java\npublic class Developer implements Cloneable {\n\n    private String name;\n    private int age;\n\n    public Developer(String name, int age) {\n        this.name = name;\n        this.age = age;\n    }\n\n    @Override\n    protected Object clone() throws CloneNotSupportedException {\n        return (Developer)super.clone();\n    }\n}\n\n// cloning or copying\nDeveloper dev = new Developer(\"Messi\", 30);\ntry {\n    Developer dev2 = (Developer) dev.clone();\n} catch (CloneNotSupportedException e) {\n    // handle exception\n}\n\n```\n\n\u003e Kotlin\n\n```kotlin\ndata class Developer(var name: String, var age: Int)\n\n// cloning or copying\nval dev = Developer(\"Messi\", 30)\nval dev2 = dev.copy()\n// in case you only want to copy selected properties\nval dev2 = dev.copy(age = 25)\n\n```\n\n---\n## Generics\n\u003e Java\n\n```java\n\n// Example #1\ninterface SomeInterface\u003cT\u003e {\n    void doSomething(T data);\n}\n\nclass SomeClass implements SomeInterface\u003cString\u003e {\n    @Override\n    public void doSomething(String data) {\n        // some logic\n    }\n}\n\n// Example #2\ninterface SomeInterface\u003cT extends Collection\u003c?\u003e\u003e {\n    void doSomething(T data);\n}\n\nclass SomeClass implements SomeInterface\u003cList\u003cString\u003e\u003e {\n\n    @Override\n    public void doSomething(List\u003cString\u003e data) {\n        // some logic\n    }\n}\n\n```\n\n\u003e Kotlin\n\n```kotlin\ninterface SomeInterface\u003cT\u003e {\n    fun doSomething(data: T)\n}\n\nclass SomeClass: SomeInterface\u003cString\u003e {\n    override fun doSomething(data: String) {\n        // some logic\n    }\n}\n\ninterface SomeInterface\u003cT: Collection\u003c*\u003e\u003e {\n    fun doSomething(data: T)\n}\n\nclass SomeClass: SomeInterface\u003cList\u003cString\u003e\u003e {\n    override fun doSomething(data: List\u003cString\u003e) {\n        // some logic\n    }\n}\n```\n\n---\n## Extension function\n\u003e Java\n\n```java\npublic class Utils {\n\n    private Utils() {\n      // This utility class is not publicly instantiable\n    }\n\n    public static int triple(int value) {\n        return 3 * value;\n    }\n\n}\n\nint result = Utils.triple(3);\n\n```\n\n\u003e Kotlin\n\n```kotlin\nfun Int.triple(): Int {\n  return this * 3\n}\n\nvar result = 3.triple()\n```\n\n---\n## Defining uninitialized objects\n\u003e Java\n\n```java\nPerson person;\n```\n\n\u003e Kotlin\n\n```kotlin\ninternal lateinit var person: Person\n```\n---\n## enum\n\u003e Java\n\n```java\npublic enum Direction {\n        NORTH(1),\n        SOUTH(2),\n        WEST(3),\n        EAST(4);\n\n        int direction;\n\n        Direction(int direction) {\n            this.direction = direction;\n        }\n\n        public int getDirection() {\n            return direction;\n        }\n    }\n```\n\u003e Kotlin\n\n```kotlin\nenum class Direction(val direction: Int) {\n    NORTH(1),\n    SOUTH(2),\n    WEST(3),\n    EAST(4);\n}\n```\n---\n\n\n## Sorting List\n\u003e Java\n\n```java\nList\u003cProfile\u003e profiles = loadProfiles(context);\nCollections.sort(profiles, new Comparator\u003cProfile\u003e() {\n    @Override\n    public int compare(Profile profile1, Profile profile2) {\n        if (profile1.getAge() \u003e profile2.getAge()) return 1;\n        if (profile1.getAge() \u003c profile2.getAge()) return -1;\n        return 0;\n    }\n});\n\n```\n\n\u003e Kotlin\n\n```kotlin\nval profile = loadProfiles(context)\nprofile.sortedWith(Comparator({ profile1, profile2 -\u003e\n    if (profile1.age \u003e profile2.age) return@Comparator 1\n    if (profile1.age \u003c profile2.age) return@Comparator -1\n    return@Comparator 0\n}))\n```\n---\n\n## Anonymous Class\n\u003e Java\n\n```java\n AsyncTask\u003cVoid, Void, Profile\u003e task = new AsyncTask\u003cVoid, Void, Profile\u003e() {\n    @Override\n    protected Profile doInBackground(Void... voids) {\n        // fetch profile from API or DB\n        return null;\n    }\n\n    @Override\n    protected void onPreExecute() {\n        super.onPreExecute();\n        // do something\n    }\n};\n\n```\n\n\u003e Kotlin\n\n```kotlin\nval task = object : AsyncTask\u003cVoid, Void, Profile\u003e() {\n    override fun doInBackground(vararg voids: Void): Profile? {\n        // fetch profile from API or DB\n        return null\n    }\n\n    override fun onPreExecute() {\n        super.onPreExecute()\n        // do something\n    }\n}\n```\n---\n## Initialization block\n\u003e Java\n\n```java\npublic class User {\n    {  //Initialization block\n        System.out.println(\"Init block\");\n    }\n}\n\n```\n\n\u003e Kotlin\n\n```kotlin\n   class User {\n        init { // Initialization block\n            println(\"Init block\")\n        }\n    }\n```\n\n---\n\n### Important things to know in Kotlin\n\n- [Mastering Kotlin Coroutines](https://outcomeschool.com/blog/kotlin-coroutines) - Mastering Kotlin Coroutines\n- [Dispatchers in Kotlin Coroutines](https://outcomeschool.com/blog/dispatchers-in-kotlin-coroutines) - Dispatchers in Kotlin Coroutines\n- [coroutineScope vs supervisorScope](https://outcomeschool.com/blog/coroutinescope-vs-supervisorscope) - coroutineScope vs supervisorScope\n- [CoroutineContext in Kotlin](https://outcomeschool.com/blog/coroutinecontext-in-kotlin) - CoroutineContext in Kotlin\n- [What is Flow API in Kotlin?](https://outcomeschool.com/blog/flow-api-in-kotlin) - What is Flow API in Kotlin?\n- [Long-running tasks in parallel with Kotlin Flow](https://outcomeschool.com/blog/long-running-tasks-in-parallel-with-kotlin-flow) - Long-running tasks in parallel with Kotlin Flow\n- [Retry Operator in Kotlin Flow](https://outcomeschool.com/blog/retry-operator-in-kotlin-flow) - Retry Operator in Kotlin Flow\n- [Callback to Coroutines in Kotlin](https://outcomeschool.com/blog/callback-to-coroutines-in-kotlin) - Callback to Coroutines in Kotlin\n- [Retrofit with Kotlin Flow](https://outcomeschool.com/blog/retrofit-with-kotlin-flow) - Retrofit with Kotlin Flow\n- [Room Database with Kotlin Flow](https://outcomeschool.com/blog/room-database-with-kotlin-flow) - Room Database with Kotlin Flow\n- [Remove duplicates from an array](https://outcomeschool.com/blog/remove-duplicates-from-an-array-in-kotlin) - Remove duplicates from an array in Kotlin\n- [JvmStatic Annotation in Kotlin](https://outcomeschool.com/blog/jvmstatic-annotation-in-kotlin) - JvmStatic Annotation in Kotlin\n- [JvmOverloads Annotation in Kotlin](https://outcomeschool.com/blog/jvmoverloads-annotation-in-kotlin) - JvmOverloads Annotation in Kotlin\n- [JvmField Annotation in Kotlin](https://outcomeschool.com/blog/jvmfield-annotation-in-kotlin) - JvmField Annotation in Kotlin\n- [inline function in Kotlin](https://outcomeschool.com/blog/inline-function-in-kotlin) - inline function in Kotlin\n- [noinline in Kotlin](https://outcomeschool.com/blog/noinline-in-kotlin) - noinline in Kotlin\n- [crossinline in Kotlin](https://outcomeschool.com/blog/crossinline-in-kotlin) - crossinline in Kotlin\n- [lateinit vs lazy in Kotlin](https://outcomeschool.com/blog/lateinit-vs-lazy-in-kotlin) - lateinit vs lazy in Kotlin\n- [init block in Kotlin](https://outcomeschool.com/blog/init-block-in-kotlin) - init block in Kotlin\n- [Retrofit with Kotlin Coroutines](https://outcomeschool.com/blog/retrofit-with-kotlin-coroutines) - Retrofit with Kotlin Coroutines\n- [Advantage of using const in Kotlin](https://outcomeschool.com/blog/const-in-kotlin) - Advantage of using const in Kotlin\n- [AssociateBy - List to Map in Kotlin](https://outcomeschool.com/blog/associateby-list-to-map-in-kotlin) - Kotlin Collection Functions - associateBy that converts a list into a map\n- [partition - filtering function in Kotlin](https://outcomeschool.com/blog/partition-filtering-function-in-kotlin) - partition - filtering function in Kotlin\n- [Infix notation in Kotlin](https://outcomeschool.com/blog/infix-notation-in-kotlin) - Infix notation in Kotlin\n- [Open keyword in Kotlin](https://outcomeschool.com/blog/open-keyword-in-kotlin) - Open keyword in Kotlin\n- [Companion object in Kotlin](https://outcomeschool.com/blog/companion-object-in-kotlin) - Companion object in Kotlin\n- [Extension function in Kotlin](https://outcomeschool.com/blog/extension-function-in-kotlin) - Extension function in Kotlin\n- [data class in Kotlin](https://outcomeschool.com/blog/data-class-in-kotlin) - data class in Kotlin\n- [How does the Kotlin Multiplatform work?](https://outcomeschool.com/blog/how-does-the-kotlin-multiplatform-work) - How does the Kotlin Multiplatform work?\n\n## Join **Outcome School** and get high paying tech job: [Outcome School](https://outcomeschool.com)\n\n### Found this project useful :heart:\n* Support by clicking the :star: button on the upper right of this page. :v:\n\n### License\n```\n   Copyright (C) 2024 Amit Shekhar\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n\n### Contributing to From Java To Kotlin\nJust make a pull request. You are in!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famitshekhariitbhu%2Ffrom-java-to-kotlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famitshekhariitbhu%2Ffrom-java-to-kotlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famitshekhariitbhu%2Ffrom-java-to-kotlin/lists"}