"Java Fundamentals" "Lesson Two" basic array types

Source: Internet
Author: User

As the first chapter said, this study in order to fast, so the explanatory text does not want to write too much, direct code bar, the code as far as possible add some comments:

1  Packagea.b;2 3  Public classTest4 {5 6     Static voidbasicvariables ()7     {8         //I. The type of learning of variables9System.out.println ("One, variable type of learning");Ten          One         //byte table range: -128~127, storage size of 1byte A         byteA; -A = 12; -SYSTEM.OUT.PRINTLN ("Byte num is" +a); the                  -         //int accounted for 4 bytes -         intb; -b = 66633; +SYSTEM.OUT.PRINTLN ("int num is" +b); -              +         //Short occupies 2 bytes A          ShortC; atc = 1234; -SYSTEM.OUT.PRINTLN ("Short num is" +c); -          -         //Long is 2 bytes -         LongD; -D = 655366; inSYSTEM.OUT.PRINTLN ("Long num is" +d); -          to         floate; +E = (float) 12.6; -SYSTEM.OUT.PRINTLN ("Fload num is" +e); the                  *         //int accounted for 4 bytes $         DoubleF;Panax Notoginsengf = 33.4; -SYSTEM.OUT.PRINTLN ("Double num is" +f); the              +         //Short occupies 2 bytes A         CharG; theg = ' a '; +SYSTEM.OUT.PRINTLN ("Char num is" +g); -          $         //Long is 2 bytes $         Booleanh; -h =true; -SYSTEM.OUT.PRINTLN ("Boolean num is" +h); the     } -     Wuyi     Static voidaboutarrays () the     { -         //second, the learning of arrays WuSystem.out.println ("Second, array learning"); -          About          $         //basic Type array assignment, output -         int[]a; -A =New int[5]; -          AA[0] = a[1] = a[2] = a[3] = a[4] = 9; +          the          for(inti = 0; I < 5; i++)  -         { $ System.out.println (A[i]); the         } the          the         //basic Type array assignment, output the         int[]B =New int[5]; -          in          for(inti = 0; I < 5; i++)  the         { theB[i] = A[i] + i +1; About System.out.println (B[i]); the         } the          the         //assignment of primitive type array initialization time +         int[]C =New int[] {3,4,5,6,7}; -                  the          for(inti = 0; I < 5; i++) Bayi         { the System.out.println (C[i]); the         } -          -         //character Array theString []d =NewString [] {"You", "is", "my", "small", "Apple"}; the                          the          for(inti = 0; I < 5; i++)  the         { - System.out.println (D[i]); the         } the     } the     94      Public Static voidMain (string[] args) the     { the         //first, basic variables the basicvariables ();98          About         //Second, array - aboutarrays ();101     }102     103     104      the}

With the result of the output:

I. Types of variables learning byte num is 12int num are 66633short num is 1234long num be 655366fload num is 12.6double num was 33.4char num is Aboolean num is true two, array of learning 99999101112131434567youaremysmallapple

"Java Fundamentals" "Lesson Two" basic array types

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.