One-dimensional array of Java arrays

Source: Internet
Author: User
Tags array definition

http://www.verejava.com/?id=16992640551624

/* Array Classification 1. One-dimensional array 1.1 definition and initialization of one-dimensional array 1.2 operations on a one-dimensional array, traversal, add, insert, modify, delete, sort, find 2. Two-dimensional array 2.1 The definition and initialization of a two-dimensional array 2.2 The traversal of a two-dimensional array 3. Multidimensional Array 4.        Enhanced for Loop */public class array{public static void Main (string[] args) {//one-dimensional array definition and initialization//static definition one-dimensional array        Int[] scores={90,70,50,80,60,85};        Dynamically define one-dimensional arrays int[] arr=new int[6];        arr[0]=90;        arr[1]=70;        arr[2]=50;        arr[3]=80;        arr[4]=60;        arr[5]=85;        One-dimensional array traversal, printing the scores for the group scores for (int i=0;i<scores.length;i++) {System.out.print (scores[i]+ ",");                The}}//array is a string of 1public class Test1 {public static void main (string[] args) {//A set of books is placed on the bookshelf to print out the title of this group of books Create a book shelf, define an empty storage book array 0,1,2,3 string[] books=new string[4];        4 is the length of the array//the book is deposited into an array books books[0]= "Jobs biography";        Books[1]= "From Excellence to Excellence";        Books[2]= "Life does not set limits";                Books[3]= "attitude decides everything";        Print out the title of this group of books//system.out.println (books[2]);        Traversal of an arraySystem.out.println (books.length);        The number of elements in the array for (int i=0;i<books.length;i++) {System.out.println (books[i]); The}}//array is a string of 2public class Test2 {public static void main (string[] args) {//defines an initialized array in        T a=0;                String[] books={"Jobs biography", "from excellent to excellent", "Life is not set limits", "Attitude decision everything"};        for (int i=0;i<books.length;i++) {System.out.println (books[i]);        }//Wang Tao in the examination of Chinese, mathematics, English, respectively, int[] scores={90,95,100};        for (int i=0;i<scores.length;i++) {System.out.println (scores[i]); }    }}

http://www.verejava.com/?id=16992640551624

One-dimensional array of Java arrays

Related Article

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.