java oop sl275 full version 0 0 4 - İTÜ

4 downloads 1415 Views 126KB Size Report
Java Programming Practice SessionPractice Session write a method public static int[] ins(int[] a,int x) which takes a sorted integer array, a, and an integer value
Objectives Objectives

ARRAYS

5

5

►Explain why elements of an array are initialized

Arrays

►Declare and create arrays of primitive, class, or array types

►Given an array definition, initialize the elements of an array ►Determine the number of elements in an array ►Create a multidimensional array ►Write code to copy array values from one array type to another

Java Programming

144

Java Programming

145

Creating Creating Arrays Arrays Use the new keyword to create an array object.

• Declare arrays of primitive or class types

For example, a primitive (char) array:

5

• Group data objects of the same type

Arrays

char s[];

Arrays

5

Declaring Declaring Arrays Arrays

Point p[];

public char[] createArray() createArray() { char[] s;

char [] s;

s = new char[26] ;

Point [] p;

for (int (int i=0; i

Suggest Documents