将函数从java转换为kotlin
我尝试在Kotlin项目中使用java函数,并在中自动转换为Kotlin,但仍然有一个错误将函数从java转换为kotlin,java,android,string,function,kotlin,Java,Android,String,Function,Kotlin,我尝试在Kotlin项目中使用java函数,并在中自动转换为Kotlin,但仍然有一个错误 if (ch.toInt() >= 0x0660 && ch.toInt() <= 0x0669) ch -= 0x0660 - '0' else if (ch.toInt() >= 0x06f0 && ch.toInt() <= 0x06F9) ch -= 0x06f0 - '0'
if (ch.toInt() >= 0x0660 && ch.toInt() <= 0x0669)
ch -= 0x0660 - '0'
else if (ch.toInt() >= 0x06f0 && ch.toInt() <= 0x06F9)
ch -= 0x06f0 - '0'
if(ch.toInt()>=0x0660&&ch.toInt()=0x06f0&&ch.toInt()这是因为kotlin不在char和int之间键入cast。您必须在'0'
上调用.toInt()
,就像您对char所做的那样。int
类只支持减去以下类型:
字节
Short
Int
Long
Float
Double
另一方面,Char
仅支持Char
和Int
的减号运算符功能
什么是ch
如果你不懂该语言,为什么要尝试使用Kotlin?它们是可互操作的,因此你最好在大多数情况下坚持使用Java,边学边用。