Arrays provide fast random access by letting you use an index position to get any element in the array.
– Arrays must be given a size! – Determining the size of an array
Arrays declartaion: TypeName[] Array
Create an int value array:1.declare an array and determine the size of the array(int[] num=new int[7])
2.Given an element of each array
Things to remember about arrays …
• An array is an object, even though it may be an array of primitives! • Array elements can be either primitives or objects.
The"String[] args"in main method is also an array
Create an array of objects:
1.Declare array 2.Create new array with a length 3.Give each element in the array a value
Printing arrays and the toString() method
重写toString方法以获取想要的结果,否则只能得到哈希值
Copying Arrays
Reference copying is true, regardless of whether your array contains primitive or reference variables. • THREE ways copy the data type variables: 1. Use a loop to copy all individual elements. 2. Use the static arraycopy method in the System class. 3. Use the clone method to copy arrays. (Out of scope)
passing arrays to method
The idea of javadocs is to be able to easily generate a code “maintenance manual”. • Run the javadoc tool over the source code, to parse the declarations and Doc comments, generating a set of HTML pages. • General form of Doc comments – A Doc comment is made up of two parts: a description, followed by zero or more tags, with a blank line (containing a single asterisk (*)) between these two sections.