Skip to content

Instantly share code, notes, and snippets.

@dwichan0905
Created April 12, 2020 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwichan0905/1533d516429164b8ec1892adba300b0d to your computer and use it in GitHub Desktop.
Save dwichan0905/1533d516429164b8ec1892adba300b0d to your computer and use it in GitHub Desktop.
Membuat pencarian kalimat sederhana di dalam suatu array 2D
import java.util.Scanner;
/**
*
* @author Dwi Candra Permana
*/
public class CobaSplit {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner sc = new Scanner(System.in);
String[][] str = {{"<pbo>", "Pemrograman Berbasis Objek"},
{"<uts>", "Ulangan Tengah Semester"},
{"<ukm>", "Universitas Kristen Maranatha"},
{"<fit>", "Fakultas Ilmu Teknlogi"},
{"<if>", "Teknik Informatika"}};
System.out.print("Masukkan string: ");
String inp = sc.nextLine();
String[] spl = inp.split(" ");
String hasil = "";
for (int i = 0; i < spl.length; i++) {
for(int j = 0; j < str.length; j++) {
if (spl[i].equalsIgnoreCase(str[j][0])) {
spl[i] = str[j][1];
}
}
hasil += spl[i] + " ";
}
System.out.println(hasil);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment