วิชาภาษาจาวา (java)

การใช้คำสั่ง if ภาษาจาวา (java)

ในภาษาจาวานั้นคำสั่ง if จะใช้ในการเปรียบเทียบค่าความจริง หรือค่าความเท็จ โดยมีการสร้างเงื่อนไขขึ้นมา ข้อควรจำเมื่อเรียกใช้งานคำสั่ง if คือจะทำงานก็ต่อเมื่อเงื่อนไขใน if มีค่าความจริงเป็นจริง หากมีค่าเป็นเท็จขึ้นมาคำสั่งจะไม่มีการทำงาน นอกเสียจากจะเรียกใช้คำสั่ง if else

โครงสร้างคำสั่ง if ภาษา java

if (เงื่อนไข){

}

ตัวอย่างคำสั่ง if ภาษา java

class Testif 
{
	public static void main(String[] args) 
	{
		int x = 20;
		int y = 17;
		if (x > y) {
			System.out.println("printif");
	}
	}
}
slot gacor hari ini slot qris slot gacor maxwin slot online slot gacor gampang menang slot gacor hari ini slot online slot slot slot guci777 guci777 fafatogel fafatogel fafatogel fafatogel agen138 slot agen138 slot data hk bola slot bolaslot99 bola slot agen138 link alternatif koin138 link alternatif agen138 slot ag138 slot slot gacor slot thailand