Java编程思想第四版第三章答案
程序员文章站
2022-03-20 23:00:28
10、package ch3;public class Bi {public static void main(String[] args) {int a=0xAAAAAAAA;int b=0x55555555;int a1=a&b;int a2=a|b;int a3=a^b;int a4=~a;int a5=~b;System.out.println(Integer.toBinaryString(a1));System.out.println(Integ...
10、
package ch3;
public class Bi {
public static void main(String[] args) {
int a=0xAAAAAAAA;
int b=0x55555555;
int a1=a&b;
int a2=a|b;
int a3=a^b;
int a4=~a;
int a5=~b;
System.out.println(Integer.toBinaryString(a1));
System.out.println(Integer.toBinaryString(a2));
System.out.println(Integer.toBinaryString(a3));
System.out.println(Integer.toBinaryString(a4));
System.out.println(Integer.toBinaryString(a5));
}
}
11、
ackage ch3;
public class Bi {
public static void main(String[] args) {
int a1=0x84;
boolean flag=true;
while(flag) {
a1=a1>>1;
System.out.println(Integer.toBinaryString(a1));
if(a1==0)
flag=false;
}
}
}
12、
package ch3;
public class Bi {
public static void main(String[] args) {
int a1=0xff;
boolean flag=true;
while(flag) {
a1=a1>>>1;
System.out.println(Integer.toBinaryString(a1));
if(a1==0)
flag=false;
}
}
}
13、
package ch3;
public class ShowChar {
static void showChar(char ch) {
System.out.println(Integer.toBinaryString(ch));
}
public static void main(String[] args) {
showChar('a');
showChar(' ');
showChar('4');
showChar('!');
showChar('*');
}
}
14、
package ch3;
public class Compare {
static void compare(String st1,String st2) {
System.out.println(st1==st2);
System.out.println(st1!=st2);
System.out.println(st1.equals(st2));
}
public static void main(String[] args) {
compare("hello","hello");
compare("hallo","hell");
}
}
本文地址:https://blog.csdn.net/returnadsss/article/details/110248628
上一篇: Unity实现首字母检索器