随笔分类 - 面试题
摘要:题目: 2个double的变量x,y; x=2,y=x+3/2; a: 3.5 b: 3 c: 2.0 d: 3.0 public static void main(String args[]) { double x=2; double y=x+3/2; System.out.println(y);
阅读全文
摘要:位运算& 3 >00000011 5 >00000101 3&5? 00000011 & 00000101 00000001=1
阅读全文
摘要:关于数字除以0的问题 public class Demo5 {public static void main (String args[]) { System.out.println(5.0/0.0); //Infinity无穷大的,这是错误,堆栈溢出 System.out.println(5.0/
阅读全文
摘要:关于for循环的理解 先看例题 public static void main(String[] args) { int x=1; for(System.out.print("a");x<=5;System.out.print("b")) { System.out.print("c");x++; }
阅读全文
摘要:二维数组误区 int[][] array= new int[3][]; int[][] array1= new int[][2]; 以上两种个数组创建可行吗 如果你是以行列矩阵的方式考虑,为什么有行不能有列,就错了 int [3][2]看成二叉树,三个子节点下有两个叶子节点,没有树杈哪来叶子 后面空
阅读全文
摘要:两个变量交换你明白几种 public class Test { public static void main(String[] args) { int a=1; int b=2; //第一种,临时变量发 int c=a; a=b; b=c; //第二种,加减乘除法(这里可以乘除) a=a+b; b
阅读全文
摘要:关于final修饰问题 public class Demo2 { public void test(final int[] array) { if(array.length>1) { array[0]=100; } System.out.println(Arrays.toString(array))
阅读全文
摘要:float范围为何比int大 基本数据类型大小比较:ibyte(8)<short(16)<int(32)<long(64)<float(32)<double(64) float的32bit位表示含义0(符号)00000000(幂数)000000000000000000000(小数部分) 8个bit表
阅读全文
摘要:拼接字符串 public class Demo { public static void main(String[] args) { String str1=5+"5"; String str2=5+5+"5"+5+5; String str3='5'+5+"zzt"; String str4="z
阅读全文
摘要:java类加载机制问题例题 public class B { public static B b1=new B(); public static B b2=new B(); { System.out.println("构造块"); } static{ System.out.println("静态块"
阅读全文