24.java當中的數組

來源:互聯網
上載者:User

標籤:

  • 數組的類型
     
  • 數組的定義方法
    • 一維數組的定義方法
 
  1. classTest{
  2. publicstaticvoid main(String arg []){
  3. //數組的靜態聲明法
  4. //int arr [] = {1,3,5,7,9};
  5. //數組的動態聲明法
  6. int arr []=newint[10];
  7. System.out.println("arr[]數組的長度是"+ arr.length);
  8. for(int i =0; i < arr.length; i++){
  9. System.out.println(arr[i]);
  10. }
  11. }
  12. }
結果:D:\work\src>javac Test.java D:\work\src>java Testarr[]數組的長度是100000000000 
    • 二維數組的定義方法
 
  1. classTest{
  2. publicstaticvoid main(String arg []){
  3. //二維數組的定義方法
  4. int arr [][]={{1,2,3},{4,5,6},{7,8}};
  5. //動態定義
  6. int arrl [][]=newint[3][3];
  7. for(int i =0; i < arr.length; i++){
  8. for(int j =0; j < arr[i].length; j++){
  9. System.out.println(arr[i][j]);
  10. }
  11. }
  12. }
  13. }
結果:D:\work\src>javac Test.java D:\work\src>java Test12345678 
  • 數組的操作方法



來自為知筆記(Wiz)



24.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.