简单JAVA知识复习,有兴趣的来做做

来源:互联网 发布:直播变声器软件 编辑:程序博客网 时间:2024/05/17 03:05

 

1。

public class Equivalence {

  public static viod main (String[] args) {

                      Integer n1=new Integer(47);

                       Integer n2=new Integer(47);

                       System.out.println(n1==n2);

                        System.out.println(n1!=n2);

} N1是否等于N2?    答案:不等于

2。

int x=0,y=1,z=2;

String sString="x,y,z";

System.out.println(sString+x+y+z);  ===》输出 x,y,z 012

System.out.println(y+z+sString);   ===》输出 3x,y,z 猜猜为什么?

 3.


public class helloworld {
 private int i=0;
 helloworld increment(){
 i++;
 return this;
 }
 void print(){
  System.out.println("i="+i);
 }
 public static void main(String args[]){
 
 helloworld x=new helloworld();
 x.increment().increment().increment().print();
 }
}

结果输出多少? 答案:i=3