i!=i的測試,java數組

來源:互聯網
上載者:User

標籤:

//測試i!=i的情況
public class DoubleTest{
 public static void main(String[] args){
  double i=0.0/0.0;//0.0/0.0在浮點數的規範運算中是有意義的,這個值和任何數都不相等和自己也不相等
  //java在IEEE包中規定這不是一個數,NaN
  if(i==i){
   System.out.println("YES,i==i");
  }else{
   System.out.println("NO,i!=i");
  }
 }

}


public class JiouTest{
 public static void main(String[] args){
  int i=21;
  if(i%2==1){//這個代碼只能測試正數的奇偶不能測試負數
   System.out.println("i 是奇數");
  }else{
   System.out.println("i 不是奇數");
  }
 }

}

 

數組: 1,定義數組 
  --int[] arr;數組的聲明(引用)
    arr=new int[5];執行個體化  --[]中執行個體化中要寫數組長度
 2,數組執行個體化
 3,數組賦值
 4,逐一查看數組
  --1,2合并寫法:int[] arr=new int[5];
  --聲明,執行個體化,賦初值合并:
   --int[] arr=new int[]{...,...,...}; --[]中不能寫數組長度
   --int[] arr={...,...,...};

二維數組:int[][] arr;
   arr=new int[3][5];
   int[][] arr={{1,2,3},{4,5},{6}};
 
 註:java中的數組就是對象,不能越界,否則會出現異常。


Array Copy (數組的拷貝)
 int myArray[]={1,2,3,4,5,6};
 int hold[]={10,9,8,7,6,5,4,3,2,1};
 System。arraycopy(myArray,0,hold,0,myArray.length);
   (原數組名,原數組中拷貝元素的開始位置,目標數組名,目標數組接受元素的開始位置,拷貝長度)

 

i!=i的測試,java數組

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.