/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package arrayliyan;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/**
*
* @author user
*/
public class Arrayliyan {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
ArrayList<String> data = new ArrayList<String>();
//memasukkan data kedalam array
System.out.println("Memasukan Nilai:")
for(int i=0; i<=4; i++){
BufferedReader dataIn = new BufferedReader(new
InputStreamReader( System.in) );
String name = "";
System.out.print("Nilai Angka:");
try{
name = dataIn.readLine();
}catch( IOException e ){
System.out.println("Error!");
}
data.add("Nilai Angka: " + (name));
}System.out.println("Membaca Nilai:");
System.out.print("");
//menampilkan data
for(int i=0; i<5; i++){
System.out.println(data.get(i)); //data 1
}
/*Output
Memasukan Nilai:
Data 2
Data 3
Data 4
Data 5
*/
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package arrayliyan;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/**
*
* @author user
*/
public class Arrayliyan {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
ArrayList<String> data = new ArrayList<String>();
//memasukkan data kedalam array
System.out.println("Memasukan Nilai:")
for(int i=0; i<=4; i++){
BufferedReader dataIn = new BufferedReader(new
InputStreamReader( System.in) );
String name = "";
System.out.print("Nilai Angka:");
try{
name = dataIn.readLine();
}catch( IOException e ){
System.out.println("Error!");
}
data.add("Nilai Angka: " + (name));
}System.out.println("Membaca Nilai:");
System.out.print("");
//menampilkan data
for(int i=0; i<5; i++){
System.out.println(data.get(i)); //data 1
}
/*Output
Memasukan Nilai:
Data 2
Data 3
Data 4
Data 5
*/
}