This is NOT a duplicate of In Swift, how can I declare a variable of a specific type that conforms to one or more protocols? . This question is about a specific use case where I needed a metatype and
这是参照在编译器检查本地变量k的初始化程序错误时确定分配的变量。 void flow(boolean flag) {
int k;
if (flag)
k = 3;
if (!flag)
k = 4;
System.out.println(k);
}
这段代码抛出一个编译错误: k needs to be initialized