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看看!
----------------解决方案--------------------------------------------------------
我用的JCreator 两个程序一点问题也没有 都能正确输出
怎么了 你的有问题??
----------------解决方案--------------------------------------------------------
恩!我用Eclipse就不能编译!
可能我是用的版本的问题吧!因为我用:for(float [] temperatures : temperature)这个语句的时候,编译器提示说:语法错误,仅当源级别为 5.0 时“for each”语句才可用!
看来还是得用最新的比较好!
----------------解决方案--------------------------------------------------------
我没用过 Eclipse 不过应该是版本问题
----------------解决方案--------------------------------------------------------
恩!那没办法了!
我现在也只对Eclipse使用有感觉!象用JCreator 或其他的IDE,我现在都不想用了!
不过版本问题还是容易解决的!
如果在Eclipse里不能编译的话,我就用JDK编译!
----------------解决方案--------------------------------------------------------
我认为不应该是版本的问题
两个IDE都是使用同一个JRE
----------------解决方案--------------------------------------------------------
那是为什么呢!?
还有就是,我的JRE好象有点问题!因为我一打开用JAVA编写的网页游戏时会出现这样一段话:
“无法从<\bin\server\java.dll>载入 Java Runtime Environment”
这个不知道楼上的朋友知道怎么回事吗!?
重新安装了也是一样!
----------------解决方案--------------------------------------------------------
那可能就是JRE的问题了
----------------解决方案--------------------------------------------------------
我用Eclipse3.0试过了,第一个程序的输出结果是1111111000000000000000000000000000000000000000000000000000000001
Previous result reversed:
1000000000000000000000000000000000000000000000000000000001111111
Bit count in number :
8
应该没有什么问题啊,真不知道你的问题出在哪里,不过肯定不是编译器的事
----------------解决方案--------------------------------------------------------
1111000000000000000000000000000000000000000000000000000000001111
The number rotate left 2 bits:
1100000000000000000000000000000000000000000000000000000000111111
The number rotate right 3 bits:
1111111000000000000000000000000000000000000000000000000000000001
Previous result reversed:
1000000000000000000000000000000000000000000000000000000001111111
Bit count in number :
8
----------------解决方案--------------------------------------------------------