Skip to content

Instantly share code, notes, and snippets.

@vixtory09678
Created April 2, 2019 14:08
Show Gist options
  • Save vixtory09678/8ce9e176403bc5ecc7c01e433fa7cb3f to your computer and use it in GitHub Desktop.
Save vixtory09678/8ce9e176403bc5ecc7c01e433fa7cb3f to your computer and use it in GitHub Desktop.
int age = 20;
// แบบ 1
if (age > 50) {
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไขเป็นจริง
}
// แบบ 2
if (age > 50) {
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไขเป็นจริง
} else {
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไขไม่เป็นจริง
}
// แบบ 3
if (age > 50) {
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไข age > 50 เป็นจริง ถ้าไม่เป็นจริงไปเช็คเงื่อนไขถัดไป
} else if (age > 25) {
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไข age > 25 เป็นจริง ถ้าไม่เป็นจริงไปเช็คเงื่อนไขถัดไป
} else if (age > 15) {
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไข age > 15 เป็นจริง ถ้าไม่เป็นจริงไปเช็คเงื่อนไขถัดไป
} else {
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไขใด ๆ ไม่เป็นจริง
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment