Java: Initialize multiple variables in for loop init?

后端 未结 4 1643
夕颜
夕颜 2020-11-30 02:24

I want to have two loop variables of different types. Is there any way to make this work?

@Override
public T get(int index) throws IndexOutOfBoundsException          


        
4条回答
  •  青春惊慌失措
    2020-11-30 02:35

    You can't like this. Either you use multiple variables of the same type for(Object var1 = null, var2 = null; ...) or you extract the other variable and declare it before the for loop.

提交回复
热议问题