convert from boolean to byte in java

前端 未结 3 1095
旧巷少年郎
旧巷少年郎 2021-02-18 21:26

I need to set byte value as method parameter. I have boolean variable isGenerated, that determines the logic to be executed within this method. But I can pass direc

3条回答
  •  执念已碎
    2021-02-18 21:56

    You can use this solution. I found it on this very useful page

    boolean vIn = true;
    byte vOut = (byte)(vIn?1:0);
    

提交回复
热议问题