简体   繁体   中英

Convert Kotlin class to Java

How to convert this Kotlin class to Java

sealed class RepoSearchResult {
    data class Success(val data: List<Repo>) : RepoSearchResult()
    data class Error(val error: Exception) : RepoSearchResult()
}

code source: github

I created this but I don't know if it's correct, and if it is how to return data from it?

public abstract class RepoSearchResult {
    public static class Success extends RepoSearchResult {

    }
    public static class Error extends RepoSearchResult {

    }
}

How to convert this Kotlin class to Java

sealed class RepoSearchResult {
    data class Success(val data: List<Repo>) : RepoSearchResult()
    data class Error(val error: Exception) : RepoSearchResult()
}

code source: github

I created this but I don't know if it's correct, and if it is how to return data from it?

public abstract class RepoSearchResult {
    public static class Success extends RepoSearchResult {

    }
    public static class Error extends RepoSearchResult {

    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM