问题解决了,     prt("(i < 10) && (j < 10) is"
        + ((i < 10) && (j < 10)));
    prt("(i < 10) || (j < 10) is"
        + ((i < 10) || (j < 10)))少了括号
另外我想问一下,为什么我产生的随机数,都是负数啊?谢谢。;

解决方案 »

  1.   

    //: 03:BitManipulation.java
    // 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();
    }
    }
    上面代码编译的时候出错,谁能帮忙看一下,谢谢。
      

  2.   

    To duo9(多子):其实很多简单的语法错误你只要多看看编译的英文提示完全就能解决的。