How do I use Java's bitwise operators in Kotlin?
问题 Java has binary-or | and binary-and & operators: int a = 5 | 10; int b = 5 & 10; They do not seem to work in Kotlin: val a = 5 | 10; val b = 5 & 10; How do I use Java's bitwise operators in Kotlin? 回答1: You have named functions for them. Directly from Kotlin docs As of bitwise operations, there're no special characters for them, but just named functions that can be called in infix form. for example: val x = (1 shl 2) and 0x000FF000 Here is the complete list of bitwise operations (available