Class> clazz in Kotlin
Sebastian Wright
How does Class<?> clazz look like in Kotlin ?
I'm trying to translate this method to Kotlin code and it seems like I'm stuck.
public static boolean isServiceRunning(Context context, Class<?> serviceClass) 2 Answers
fun isServiceRunning(context: Context, serviceClass : Class<Any>) : Boolean something like that should do the job
You can define it as
companion object { fun isServiceRunning(context: Context, serviceClass: Class<*>): Boolean { /* ... */ }
}The Class<*> star-projection is almost equivalent to the Java unbounded wildcard Class<?>.