java 语言,,题目是显示a语法错误,,bcd都可以访问,,但是我打出代码好像都访问不了,求大神

2025-05-20 02:57:58
推荐回答(1个)
回答1:

package com.newway.test;

public class Test {
public static void main(String[] args) {
A.a++;
A.b++;
A.c++;
A.d++;
}
}

class A {
static private int a = 1;
static int b = 2;
static protected int c = 3;
static public int d = 4;

protected void funA() {
}
}

用了你的例子,首先你之所以报错,是因为在B中你对属性的操作没有放在方法之中。