🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
变量建议置于块的开始处,不要总是在第一次使用它们的地方做声明。如 void MyMethod() { int int1 = 0; // beginning of method block if (condition) { int int2 = 0; // beginning of "if" block ... } } 不过也有一个例外 for (int i = 0; i < maxLoops; i++) { ... } 应避免不同层次间的变量重名,如 int count; ... void MyMethod() { if (condition) { int count = 0; // 避免 ... } ... }