jeudi 8 octobre 2015

Changing switch statment to if statment

I want to change this switch statement to if statement or while loop. How can I do that? Note this piece of code using Android Studio.

public void onClick(View v) {
    switch(v.getId()){
    case R.id.button:
        Log.v(TAG, "verbose");
        break;
    case R.id.button2:
        Log.d(TAG, "Debug");
        break;
    case R.id.button3:
        Log.i(TAG, "Information");
        break;
    case R.id.button4:
        Log.w(TAG, "Warning");
        break;
    case R.id.button5:
        Log.e(TAG,"Error");
        break;
    }
}

Aucun commentaire:

Enregistrer un commentaire