/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package program;
/**
*
* @author Administrator
*/
public class StringArrayBoolean166 {
public static void main(String[] args) {
String namaKota=null;
boolean found=false;
if(args.length>0){
namaKota=args[0];
}
String nkKota[]=
{"pekanbaru","bandung","semarang"};
for(int i = 0; i<nkKota.length;i++){
if(nkKota[i].equals(namaKota)){
System.out.println("kota ditemukan, yaitu kota "+nkKota[i]);
found=true;
break;
}
}
if(!found){
System.out.println("nama kota "+namaKota+" tidak ditemukan");
}
}
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package program;
/**
*
* @author Administrator
*/
public class StringArrayBoolean166 {
public static void main(String[] args) {
String namaKota=null;
boolean found=false;
if(args.length>0){
namaKota=args[0];
}
String nkKota[]=
{"pekanbaru","bandung","semarang"};
for(int i = 0; i<nkKota.length;i++){
if(nkKota[i].equals(namaKota)){
System.out.println("kota ditemukan, yaitu kota "+nkKota[i]);
found=true;
break;
}
}
if(!found){
System.out.println("nama kota "+namaKota+" tidak ditemukan");
}
}
}
0 komentar:
Post a Comment