开发者社区> 问答> 正文

java代码转换成kotlin代码报错?报错

这是原来的java写法

byte[] mac = NetworkInterface.getByInetAddress(ia).getHardwareAddress();

 

然后通过kotlin转换成

val mac = NetworkInterface.getByInetAddress(ia).hardwareAddress

然后

val temp = mac[i] and 0xff

发现报错:the integer literal does not conform to the expected type Byte

请问如何解决哦?

展开
收起
爱吃鱼的程序员 2020-06-08 14:05:16 810 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    byte和int不能做运算,你可以把0xff转换成byte类型

    2020-06-08 14:05:28
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载