String Array Boolean

/*
 * 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

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | SharePoint Demo