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