Pemrograman berbasis objek (Java)

Array (*bukan tokoh di Sang pemimpi ^_^)

 Array adalah suatu kumpulan data pada suatu variabel. Cara mendeklarasikan array adalah sebagai berikut:
    type_array nama_array[];
example :
  • int []ages; 
  • int ages[];
After declaring, we must create the array and specify its length with a constructor statement.  
Definitions:
– Instantiation
  •  In Java, this means creation
– Constructor
  •  In order to instantiate an object, we need to use a constructor for this. A
constructor is a method that is called to create a certain object.
  •  We will cover more about instantiating objects and constructors later. 


Array Instantiation
  •  To instantiate (or create) an array, write the new keyword,
followed by the square brackets containing the number of
elements you want the array to have.
  •  For example,
//declaration
 int ages[]; 
//instantiate object
ages = new int[100];
or, can also be written as,
//declare and instantiate object
int ages[] = new int[100];


Download full article in here
Share on Google Plus

About Kurnia Rahman

Kurnia Rahman Agus - Programmer lepas yang mengisi hari-harinya dengan memberikan ilmu kepada siswa-siswi di salah satu SMK di Pekanbaru. Beliau aktif di beberapa komunitas seperti Blogger Bertuah dan Baleno Club Riau.

0 comments :

Post a Comment

Terima kasih telah berkunjung, Semoga Bermanfaat..