Issue
hi guys i'm new in Koltin , in java we can do that
class A{
int x;
int y;
A(int x, int y){
this.x=x;
this.y=y
}
}
class B extends A{
int x,y;
B(int a, int b){
super(x,getSum(x,y));
}
int getSum(int x, int y){
return x+y;
}
}
how can i do this code in Kotlin ,thank's for help
Solution
Using IntelliJ IDE's Convert Java file to Kotlin file feature, here is corresponding kotlin file.
test.kt:
internal class A(var x: Int, var y: Int)
internal class B(a: Int, b: Int) : A(x, getSum(x, y)) {
var x: Int = 0
var y: Int = 0
fun getSum(x: Int, y: Int): Int {
return x + y
}
}
Answered By - Swati
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.