提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
将位设置为长值
/*时代Java公众号*/ //package com.nowjava; public class Main { public static void main(String[] argv) throws Exception { long bitmap = 2; int pos = 2; System.out.println(setBit(bitmap, pos)); } public static long setBit(long bitmap, int pos) { return bitmap | (1 << pos); } }