0% found this document useful (0 votes)
97 views1 page

Linked List - Input Data Keyboard Pada Java

The document shows code for a Java program that takes user input to populate two linked lists, one for integers and one for strings, and then prints the contents of the lists.

Uploaded by

dedyprastyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views1 page

Linked List - Input Data Keyboard Pada Java

The document shows code for a Java program that takes user input to populate two linked lists, one for integers and one for strings, and then prints the contents of the lists.

Uploaded by

dedyprastyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.io.

*;
import java.util.LinkedList;
class SoalUas1
{
public static void main(String[] args) throws IOException
{
LinkedList<Integer> A = new LinkedList<Integer>();
LinkedList<String> B = new LinkedList<String>();
int DataA;
String DataB;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
for (int i=0; i<6; i++)
{
System.out.print("Masukkan data ke-"+i+ " : ");DataA = Integer.parseInt(in.readLine());
A.add(DataA);
}
for (int i=0; i<9; i++)
{
System.out.print("Masukkan data ke-"+i+ " : ");DataB = in.readLine();
B.add(DataB);
}
System.out.println("TAMPILAN AWAL");
System.out.println(A);
System.out.println(B);
System.out.println();
System.out.println();
System.out.println(A.get(0));
System.out.println(A.get(1));
System.out.println(B.get(0));
System.out.println(B.get(1));
System.out.println(B.get(2));
System.out.println(A.get(2));
System.out.println(A.get(3));
System.out.println(B.get(3));
System.out.println(B.get(4));
System.out.println(B.get(5));
System.out.println(A.get(4));
System.out.println(A.get(5));
System.out.println(B.get(6));
System.out.println(B.get(7));
System.out.println(B.get(8));
System.out.println();
System.out.println();
System.out.println("TAMPILAN AKHIR");
System.out.println(A);
System.out.println(B);
}
}

You might also like