2016-04-19 4 views

Antwort

2

kaskadierte:

if (condition1) 
{ 
    // do one thing 
} 
if (condition2) 
{ 
    // do other thing 
} 

Wenn hier condition1 wahr ist, wird one thing erfolgen. Auch wenn condition2 wahr ist, wird other thing auch getan werden.

Nested:

if (condition1) 
{ 
    // do one thing 
    if (condition2) 
    { 
     // do other thing 
    } 
} 

Wenn hier condition1 wahr ist, wird one thing erfolgen. Und wenn condition2 ist auch wahr, other thing wird auch getan werden.

Beachten Sie, dass im letzten Fall beide Bedingungen erfüllt sein müssen, damit other thing passieren kann. Während im ersten Fall other thing passiert, wenn condition2 wahr ist, unabhängig davon, ob condition1 wahr oder falsch ist.

+0

Ich glaube nicht, ist wahr, Kaskade ist == >> 'if { } else wenn {} else wenn {} ....... {} else {} '[Siehe hier] (http://palmsforcs1.pbworks.com/w/page/13844712/CascadingIf) – Michi

+0

^Was Sie sind Bezug nehmend wird eine If-Else-If-Leiter genannt. – CinCout

+0

Ja, auch bekannt als Cascading If Anweisungen – Michi

Verwandte Themen