https://everleaf.blogspot.com/search/label/PHP

10/24/2023

Java switch select statement

Simpan script java dengan nama HelloWorld.java
	
class HelloWorld {
    public static void main(String[] args) {
        String animal = "dog";
        switch(animal){
            case "dog":
                System.out.println("found animal dog");
                break;
            case "cat":
                System.out.println("found animal cat");
                break;
            case "bird":
                System.out.println("found animal bird");
                break;
            default:
                break;
        }
    }
}
Jalankan script java : java HelloWorld.java, hasilnya:
    
found animal dog

No comments:

Post a Comment

Diharapkan berkomentar dengan sopan dan santun, terimakasih.