Arrays in 24.java

Source: Internet
Author: User

    • Types of arrays
    • How to define Arrays
      • A method for defining one-dimensional arrays
  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. }
Result: The length of the D:\work\src>javac Test.java D:\work\src>java testarr[] array is 100000000000
      • A method for defining two-dimensional arrays
  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. }
Results: D:\work\src>javac Test.java D:\work\src>java Test12345678
    • How to manipulate arrays



From for notes (Wiz)



Arrays in 24.java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.