android - Kotlin integration in Java Code? -


example: in c-code possible call parts of assembler code, like:

int main() {    //... stuff    __asm    {       lea ebx, hal       mov ecx, [ebx]hal.same_name ;       mov esi, [ebx].weasel       ;    }    // .. further stuff    return 0; } 

is such code integration possible kotlin code in java (*.java) files?

(i not talkin jni or c/c++ in java!) extend existing (androidstudio-) java-source-code kotlin language.

//.. *.java file public class myalreadyexistingjavaclass {  private int membervar;  public myalreadyexistingjavaclass() {  }  // kotlin within *.java file // extend java file constuctor in kotlin ? // make above default constructor unneccessary. class myalreadyexistingjavaclass(number: int = 0) {   membervar = number; }  } 

java not provide syntax including snippets of code in kotlin or other language java file. however, not necessary accomplish task. can define constructor need factory function in separate kotlin file:

fun myalreadyexistingjavaclass() = myalreadyexistingjavaclass(0) 

if want define new method, rather constructor, can use extension functions.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -