“Return vs Break” Kode Jawaban

Return vs Break

int i;

for(int j=0; j<10; j++)
{
    for(i=0; i<10; i++)
    {
        if(i==0)
            break;        // This break will cause the loop (innermost) to stop just after one iteration;
    }

    if(j==0)
        break;    // and then this break will cause the outermost loop to stop.
}

switch(i)
{
    case 0: break;    // This break will cause execution to skip executing the second case statement

    case 1: System.out.println("This will also never be printed");
}
Stephen Dave Machica

Return vs Break

public void myMethod()
{
    int i = 10;

    if(i==10)
        return;

    System.out.println("This will never be printed");
}
Stephen Dave Machica

Jawaban yang mirip dengan “Return vs Break”

Pertanyaan yang mirip dengan “Return vs Break”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya