Cov txheej txheem:

Yuav ua li cas yog lwm yam yog hais tias nyob rau hauv Java?
Yuav ua li cas yog lwm yam yog hais tias nyob rau hauv Java?

Video: Yuav ua li cas yog lwm yam yog hais tias nyob rau hauv Java?

Video: Yuav ua li cas yog lwm yam yog hais tias nyob rau hauv Java?
Video: yuav ntseeg li cas thiaj hu tau tias yog tus ntseeg tiag. 2024, Plaub Hlis Ntuj
Anonim

Java ifelse ( yog - ces - lwm tus ) Nqe lus

Cov yog hais tias executes ib seem ntawm code yog qhov kev ntsuam xyuas qhia yog ntsuas kom muaj tseeb. Cov yog hais tias tej zaum yuav muaj kev xaiv lwm tus thaiv. Nqe lus hauv lub cev ntawm lwm nqe lus raug tua yog qhov kev ntsuam xyuas qhia yog ntsuas rau qhov tsis tseeb.

Ntawm no, yuav ua li cas koj sau ib nqe lus yog Java?

Java muaj cov ntsiab lus hauv qab no:

  1. Siv yog kom qhia meej txog qhov thaiv ntawm cov lej yuav tsum tau ua, yog tias qhov xwm txheej muaj tseeb.
  2. Siv lwm tus los qhia txog qhov thaiv ntawm cov lej kom raug tua, yog tias tib yam xwm txheej tsis tseeb.
  3. Siv lwm tus yog kom qhia meej qhov xwm txheej tshiab los sim, yog tias thawj qhov xwm txheej tsis tseeb.

Ib yam li ntawd, koj sau ib nqe lus yog li cas? Siv cov IF muaj nuj nqi, ib qho ntawm cov laj thawj ua haujlwm, kom rov qab ib tus nqi yog ib qho xwm txheej muaj tseeb thiab lwm tus nqi yog nws yog cuav. Piv txwv li: = IF (A2>B2, "Over Budget", "OK") = IF (A2 = B2, B4-A4, "")

Tom qab ntawd, ib tug kuj yuav nug, yuav ua li cas koj xaus ib nqe lus yog Java?

Cov lus txib "break" tsis ua haujlwm hauv ib qho " yog " nqe lus . Yog koj tshem tawm cov lus txib "so" los ntawm koj cov cai thiab tom qab ntawd sim cov lej, koj yuav tsum pom tias cov lej ua haujlwm raws nraim tib yam tsis muaj "so" hais kom ua nrog ib qho. "Luag" yog tsim los siv rau hauv lub voj voog (rau, thaum, ua-ntev, txhim kho rau thiab hloov).

Yuav ua li cas yog tias / tom qab ntawd lwm nqe lus?

Yog / Ces / Lwm Cov Lus Qhia . Cov yog / ces nqe lus yog conditional nqe lus uas executes nws sub- nqe lus , uas ua raws li cov ces lo lus tseem ceeb, nkaus xwb yog qhov muab mob ntsuas qhov tseeb: yog x <10 ces x:= x+1; Nyob rau saum toj piv txwv , cov mob yog x <10, thiab cov nqe lus execute yog x: = x + 1.

Pom zoo: