Pemrograman Java (2)

Nama : Agus Wijayanto
Kelas : TI – 3G
NIM : 13.01.203

PEMROGRAMAN JAVA
Array
Array adalah sekumpulan data yang memiliki integer
*Array Satu Dimensi
Int a ; //deklarasi
a = 2 //inisiasi
Int a [] ;
Int []a ;
String []a ;
*Array Multidimensi
int a[][]={{1,2,3},{4,5,6}};
Praktek 1
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package agus_20112014;

/**
*
* @author User
*/
public class Agus_20112014 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//Cara Pertama
/**
int [] a = {1,2,3};
String [] b = {"Senin","Selasa","Rabu"};

System.out.println(a[0]+". "+b[0]);
System.out.println(a[1]+". "+b[1]);
System.out.println(a[2]+". "+b[2]);
*/
//Cara Kedua
/**
int []a = new int [3];
a[0]=1;
a[1]=2;

a[2]=3;

String [] b = new String [3];
b[0]="Senin";
b[1]="Selasa";
b[2]="Rabu";

System.out.println(a[0]+". "+b[0]);
System.out.println(a[1]+". "+b[1]);
System.out.println(a[2]+". "+b[2]);
*/
//Cara Ketiga
int a[]= new int [3];
String b[]= {"Senin","Selasa","Rabu"};
for(int i=0;i

Dokumen yang terkait

Dokumen baru