import static java.lang.Long.*;
public class TryBitMethods
{
public static void main(String args[])
{
long number = 0xF00000000000000FL;
System.out.println("The number is :\n" + toBinaryString(number));
long result = rotateLeft(number ,2);
System.out.println("The number rotate left 2 bits:\n" +toBinaryString(result));
result = rotateRight(number,3);
System.out.println("The number rotate right 3 bits:\n"+ toBinaryString(result));
result = reverse(result);
System.out.println("Previous result reversed:\n" +toBinaryString(result));
System.out.println("Bit count in number :\n" + bitCount(number));
}
}
====================================================================================================
public class TryEnumeration
{
//Define an enumeration type for days of the week
enum Day {Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday}
public static void main(String args[])
{
//Define three variables of type Day
Day yesterday = Day.Thursday;
Day today = Day.Friday;
Day tomorrow = Day.Saturday;
//Output the values of the Day rariables
System.out.println("Today is "+today);
System.out.println("Tomorrow will be "+tomorrow);
System.out.println("Yesterday was "+yesterday);
}
}
斑竹,你说这两个程序是不是正常的!?你用Eclipse之类的IDE看看!