
有這樣的一段代碼,為什么我ip定義在new Runnable 外就會報錯(Local variable ip defined in an enclosing scope must be final or effectively final);但是req就不會報錯?
uj5u.com熱心網友回復:
重寫執行緒類的run方法,里面的ip作用域是在執行緒類中 外面的ip作用域是main方法那個new Runnable()里面的都是類中的資料
class Temp implements Runnable{
public void run(){
String ip="";
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/268153.html
標籤:Web 開發
