问题解决了, prt("(i < 10) && (j < 10) is"
+ ((i < 10) && (j < 10)));
prt("(i < 10) || (j < 10) is"
+ ((i < 10) || (j < 10)))少了括号
另外我想问一下,为什么我产生的随机数,都是负数啊?谢谢。;
+ ((i < 10) && (j < 10)));
prt("(i < 10) || (j < 10) is"
+ ((i < 10) || (j < 10)))少了括号
另外我想问一下,为什么我产生的随机数,都是负数啊?谢谢。;
解决方案 »
- java 官方有没有出中文文档呢??
- The import javax.media cannot be resolved 请问如何解决?
- 请帮我改一下这个程序
- 多线程出现NullPointerException怎么解决?
- 编写一个程序:输出整数的补码形式的二进制数,八进制数,十六进制数。
- 接着提个初级的问题,谢谢!
- 请帮我看看这个读写注册表的问题
- java初学者,在线等候。
- interface里面只能定义public成员,为什么clone为protected类型啊
- 怎样获取系统时间,显示成“年月日时分秒”的格式?
- 菜鸟提问 JDK和SDK一样吗??........................
- 在线急求帮助
// Using the between operators.
import java.util.*;public class BitManipulation{
public static void main(String[] args){
Random rand = new Random();
int i = rand.nextInt();
int j = rand.nextInt();
pBinInt("-1", -1);
pBitInt("+1", +1);
int maxpos = 2147483647;
pBitInt("maxpos", maxpos);
int maxneg = -2147483648;
pBitInt("maxneg", maxneg);
pBitInt("i", i);
pBitInt("~i", ~i);
pBitInt("-i", -i);
pBitInt("j", j);
pBitInt("i & j", i & j);
pBitInt("i | j", i | j);
pBitInt("i ^ j", i ^ j);
pBitInt("i << 5", i << 5);
pBitInt("i >> 5", i >> 5);
pBitInt("(~i) << 5", (~i) << 5);
pBitInt("i >>> 5", i >>> 5);
pBitInt("(~i) >>> 5", (~i) >>> 5);
long l = rand.nextLong();
long m = rand.nextLong();
pBinLong("-1L", -1L);
pBinLong("+1L", +1L);
long ll = 9223372036854775807L;
pBinLong("maxpos", ll);
long lln = -9223372036854775808L;
pBinLong("maxneg", lln);
pBinLong("l", l);
pBinLong("~l", ~l);
pBinLong("-l", -l);
pBinLong("m", m);
pBinLong("l & m", l & m);
pBinLong("l | m", l | m);
pBinLong("l ^ m", l ^ m);
pBinLong("l << 5", l << 5);
pBinLong("l >> 5", l >> 5);
pBinLong("(~l) << 5", (~l) << 5);
pBinLong("l >>>5", l >>> 5);
pBinLong("(~l) >>> 5", (~l) >>> 5);
}
static void pBinInt(String s, int i){
System.out.println(
s + ", int:" + i + ", binary:");
System.out.println(" ");
for(int j = 31; j >= 0; j--)
if(((1 << j) & i) != 0)
System.out.println("1");
else
System.out.println("0");
System.out.println();
}
static void pBinLong(String s, long l){
System.out.println(
s + ",long:" + l +", binary:");
System.out.println(" ");
for(int i = 63; i >= 0; i--)
if(((1L << i) & l) != 0)
System.out.println("1");
else
System.out.println("0");
System.out.println();
}
}
上面代码编译的时候出错,谁能帮忙看一下,谢谢。