amitshekhariitbhu / from-java-to-kotlin Goto Github PK
View Code? Open in Web Editor NEWFrom Java To Kotlin - Your Cheat Sheet For Java To Kotlin
Home Page: https://outcomeschool.com
License: Apache License 2.0
From Java To Kotlin - Your Cheat Sheet For Java To Kotlin
Home Page: https://outcomeschool.com
License: Apache License 2.0
add a future example from java to kotlin
public Future ...
Under Logical operators you have used Bitwise operators in Java
Java
public class Utils {
private Utils() {
// This utility class is not publicly instantiable
}
public static int triple(int value) {
return 3 * value;
}
}
int result = Utils.triple(3);
Kotlin
fun Int.triple(): Int {
return this * 3
}
var result = 3.triple()
var result = 3.triple() is it same function as in Java called Utils.triple(3) ?
If yes than 3 how can be an object ?
enum class Direction constructor(direction: Int) {
NORTH(1),
SOUTH(2),
WEST(3),
EAST(4);
var direction: Int = 0
private set
init {
this.direction = direction
}
}
could be
enum class Direction(val direction: Int) {
NORTH(1),
SOUTH(2),
WEST(3),
EAST(4);
}
Please add commons patterns, thanks 🙏
Would it be possible to consider adding Java code decompiled from Kotlin for each example? This would make it more intuitive to see the differences between the two.
An example is as follows:
Java
System.out.print("Amit Shekhar");
System.out.println("Amit Shekhar");
Kotlin
print("Amit Shekhar")
println("Amit Shekhar")
Java(Decompiled from the above Kotlin code)
System.out.print((Object) "Amit Shekhar");
System.out.println((Object) "Amit Shekhar");
We are now develop a new forum Kotlin China for chinese Kotlin learner. We'd like to request your permission to let us repost your article to our site.
In this java to kotlin comparison
Java
if(object instanceof Car){
}
Car car = (Car) object;
Kotlin
if (object is Car) {
}
var car = object as Car
Shouldn't the casting be inside the braces, i.e
Java
if(object instanceof Car){
Car car = (Car) object;
}
Kotlin
if (object is Car) {
var car = object as Car
}
show usage of lateinit like:-
FirebaseDatabase database; (java)
internal lateinit var database: FirebaseDatabase (kotlin)
Hi, this is more of a request & not an issue. Would it be possible to rule-out case sensitivity on "Kotlin"?
thanks in adv.
var otherName : String?
otherName = null
It should be like this if I'm not wrong ?
var otherName : String? = null
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.