开发者社区 问答 正文

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 911 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

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

    2020-06-08 14:05:28
    赞同 展开评论