There are several errors in this code:

  1. The 'printIn' method should be 'println'.
  2. The 'Nested' class is missing a closing parenthesis after the class declaration.
  3. The 's' variable is not static and cannot be accessed from the 'Nested' class.

Here is the corrected code:

public class Test {
  private static int value = 20;
  public static int temp = 10;

  public static class Nested {
    private void display() {
      System.out.println(temp + value);
    }
  }

  public static void main(String[] args) {
    Test.Nested inner = new Test.Nested();
    inner.display();
  }
}

This will print out the value 30, which is the sum of the static variables 'temp' and 'value'. The non-static variable 's' cannot be accessed from the 'Nested' class.

Java Code Errors: Fixing Nested Class Access and Method Usage

原文地址: https://www.cveoy.top/t/topic/mXED 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录