合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
# 静态方法中的 this --- ## 问题 下面程序片段有没有编译错误?为什么? ``` package com.devin.test; public class Account { public static int level; public static int test() { return this.level; } } ``` ## 结果 第5行有编译错误,因为在静态方法中不能使用this关键字。 ## 结论 #### this 关键字指的是当前的一个引用,而 static 方法与对象无关,是所有对象共享的,所以不能使用 this。