2
我想了解在Java中的開關的case語句中這是如何有效。在開關中的java變量的範圍
switch(someValue){
case abc: int i=0
break;
case def: int i=0 // error because i declared above is still accessible in this case.`
如果我們說變量在Java中有一個塊範圍,那麼在def的情況下不應該使用「i」變量嗎?或者這種情況不被視爲一個區塊? 很多人以前一定遇到過這個問題。
這爲什麼不違反編程的基本概念?
的'之開關定義了一個塊,而不是'case'。 – 2015-03-13 20:03:28
ohhk得到了你,謝謝... – user1079065 2015-03-13 20:04:08