浏览后我知道Stackoverflow错误是由于方法的递归调用,这是我的代码,我得到上述错误,但无法解决这个问题。
public static GameLayer sharedGameLayer() {
return sharedGameLayer();
}
logcat错误
09-16 15:13:30.074: E/AndroidRuntime(1597): FATAL EXCEPTION: main
09-16 15:13:30.074: E/AndroidRuntime(1597): java.lang.StackOverflowError
09-16 15:13:30.074: E/AndroidRuntime(1597): at com.ps.GameLayer.sharedGameLayer(GameLayer.java:533)
09-16 15:13:30.074: E/AndroidRuntime(1597): at com.ps.GameLayer.sharedGameLayer(GameLayer.java:533)
09-16 15:13:30.074: E/AndroidRuntime(1597): at com.ps.GameLayer.sharedGameLayer(GameLayer.java:533)
09-16 15:13:30.074: E/AndroidRuntime(1597): at com.ps.GameLayer.sharedGameLayer(GameLayer.java:533)
答案 0 :(得分:4)
您的方法以递归方式调用自身,导致您的堆栈用完。