Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Class clazz in Kotlin

Writer 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<?>.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy