Created
April 12, 2020 14:08
-
-
Save dwichan0905/1533d516429164b8ec1892adba300b0d to your computer and use it in GitHub Desktop.
Membuat pencarian kalimat sederhana di dalam suatu array 2D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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