java小结

int i=1;int j;j=i++;(结果i=2,j=1);减法同理

int i=1;int j;j=++i;(结果i=2,j=2);

 int i=5;
  do {
System.out.println(i);
} while (i-->3);输出5,4,3

 int i=5;
  do {
System.out.println(i);
} while (--i>3);输出5,4

2.

arithmetic right shift operator,算术右移运算符,>>表示带符号右移,左边补上符号位 

logical right shift operator,逻辑右移运算符;>>>无符号右移无符号,左边补0 

3正确表达

    float a=2.0f;double a=2.0;    double b=2;    int c=2; long d=2;  long d=2L;
    long f=2;    float y=2;
    long h=2l;

4正确的创造数组

   float f[][]=new float[6][6];

   float []f[]=new float[6][6];

   float [][]f=new float[6][6];后面两个不能为空。

5

 int m[]={0,1,2,3,4,5,6};属性
  String n="asiaking";方法
  System.out.println(m.length+"to"+n.length());7to8

6

 boolean m=true;
  if (m=false) (m==false也对)
 System.out.println("False");
  else  
  System.out.println("true");

结果为true,if到else中间这段不执行。

7

outer:for (int i = 0; i < 3; i++) 
inner:for (int j = 0; j < 2; j++) {
if (j==1) continue outer;
System.out.println(j++ +"to"+ ++i);


}结果0to1
0to3;

8

     switch(m){
     case 0:System.out.println("0");
     case 1:System.out.println("1");
     case 2:System.out.println("condition2");break;
     case 3:System.out.println("condition3");break;
     default:System.out.println("other condintion");
     }注意break,m=0输出0,1,condition2;

m=1输出,1,condition2;

m=2输出condition2;

9

public class test{
private float f=1.0f;
int m=12;
static int n=1;
public static void main(String args[]) {  
     test t=new test();
     System.out.println(t.f);
    // System.out.println(this.n);//错
    // System.out.println(test.m);//错
     System.out.println(test.n);
     
}  
  }
10

public class Example{
Double d1=new Double(1.0);
Double d2=new Double(1.0);
public static void main(String args[]) {  


Double d1=new Double(1.0);
Double d2=new Double(1.0);
Float f=new Float(1.0F);
System.out.println(d1==d2);
System.out.println(d1.equals(d2));
System.out.println(f.equals(d1)); 
}  
  }

false
true
false

11





  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值