I noticed, one interesting thing.
Java's Integer.MAX_VALUE is 0x7fffffff (2147483647)
Kotlin's Int.MAX_VALUE is 2147483647
but if you write
in Java:
int value = 0xFFFFFFFF; //everything is fine (but printed value is '-1')
in Kotlin:
val value: Int = 0xFFFFFFFF //You get exception The integer literal does not conform to the expected type Int

Interesting right? So you're able to do something like new java.awt.Color(0xFFFFFFFF, true) in Java but not in Kotlin.

Color类在"二进制"级别上使用该int,因此所有构造函数(Color(int rgba)Color(int r, int g, int b, int a))在两个平台上都工作得很好.
我为Kotlin 找到的唯一变通办法是java.awt.Color(0xFFFFFFFF.toInt(), true).

Any idea why is it like this in Kotlin?

推荐答案

I think, this problem should be solved by Kotlin 1.3 and UInt See more here: https://kotlinlang.org/docs/reference/whatsnew13.html#unsigned-integers

Kotlin相关问答推荐

Lambda和普通Kotlin函数有什么区别?

CompositionLocal 究竟如何以及何时隐式设置值?

如何使用 Kotlin Maven 更改 Minecraft 插件中的 Shulker GUI 标题

Kotlin 复制列表中的项目以创建具有相同数据的不同对象的新列表

Kotlin 函数有 2 个参数用于对 Map 或 List 进行排序

每个 Kotlin 版本的默认 Kotlin 语言版本是什么?

如何处理基于枚举提前返回的 forEach 循环,Kotlin 中的一条路径除外

如何缩短 MaterialTheme.colors.primary?

如何将glide显示的图像下载到设备存储中.Kotlin

嵌套数组 indexOf()

Kotlin JS JSON 反序列化

Swift vs Kotlin 在排序数组上的表现

runBlocking 中的 deferred.await() 抛出的异常即使在被捕获后也被视为未处理

如何从定义它们的类外部调用扩展方法?

如何用 kotlin 打包 List

如何解决此错误请Kotlin:[Internal Error] java.lang.ExceptionInInitializerError

将多个 Kotlin 流合并到一个列表中,而无需等待第一个值

Jetpack Compose State:修改类属性

接口中的属性不能有支持字段

Android room DAO 接口不适用于继承