Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In fact, there's nothing wrong with your code, it's working fine. I guess you're using eclipse, then when you're debugging with Android it always goes to the last return line in the method, it just reach there but not execute that line (this should be a bug of eclipse). <br><br> I added some logs into your code like this:</p> <pre><code>public static void getMinMaxValuesForNumberPicker() { Log.i("TestActivity", "Your method *******************"); int type = 0; int min1 = 0, min2 = 0, max1 = 0, max2 = 0; switch (type) { case 0: // cm bzw. ft + in { // 0 - 3m (3m ~ 9.84ft) if (min1 &gt; min2) { min1 = 0; max1 = 300; } else { min1 = 0; max1 = 10; min2 = 0; max2 = 11; // &lt;= 1) IS REACHED Log.i("TestActivity", " 1) IS REACHED"); } Log.i("TestActivity", " 2) IS REACHED"); return; // &lt;= 2) IS NOT REACHED } case 1: // cm bzw. in { // 0 - 500cm (500cm ~ 196.85in) if (min1 == 1) { min1 = 0; max1 = 500; } else { min1 = 0; max1 = 200; } return; } case 2: // cm bzw. in { // 0 - 50cm (50cm ~ 19.69in) if (min1 &lt; min2) { min1 = 0; max1 = 50; } else { min1 = 0; max1 = 20; } return; } case 3: // km + m bzw. mi + yd { // 0 - 1000km (1000km ~ 621.37mi) if (min1 &lt; min2) { min1 = 0; max1 = 1000; min2 = 0; max2 = 999; } else { min1 = 0; max1 = 500; min2 = 0; max2 = 1759; } Log.i("TestActivity", " 3) IS REACHED"); return; // &lt;= 3) IS REACHED } default: throw new RuntimeException("getMinMaxValuesForNumberPicker für " + type + " nicht implementiert!"); } } </code></pre> <p>And the logs make things clear:</p> <pre><code>12-05 01:35:24.808: I/TestActivity(3784): Your method ******************* 12-05 01:35:24.808: I/TestActivity(3784): 1) IS REACHED 12-05 01:35:24.808: I/TestActivity(3784): 2) IS REACHED </code></pre> <p>And, two more testing methods to make it more clear, you can try debugging them, it always reaches the last return line in the method</p> <pre><code>public static void testDebugingLine(int number) { Log.i("TestActivity", "Another example *******************"); if (number &lt; 0) { Log.e("TestActivity", "1 is reached"); return; } Log.e("TestActivity", "2 is reached"); return; } public static boolean testDebugingLine1(int number) { Log.i("TestActivity", "And another example *******************"); if (number &lt; 0) { Log.e("TestActivity", "1 is reached and return true"); return true; } Log.e("TestActivity", "2 is reached and return false"); return false; } </code></pre> <p><br></p> <pre><code> testDebugingLine(-1); boolean result = testDebugingLine1(-1); Log.e("TestActivity", "testDebugingLine1() return " + result); </code></pre> <p>Logs:</p> <pre><code>12-05 01:35:24.808: I/TestActivity(3784): Another example ******************* 12-05 01:35:27.861: E/TestActivity(3784): 1 is reached 12-05 01:35:32.326: I/TestActivity(3784): And another example ******************* 12-05 01:35:34.368: E/TestActivity(3784): 1 is reached and return true 12-05 01:35:42.497: E/TestActivity(3784): testDebugingLine1() return true </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload