Why can I access a private variable from main method?

后端 未结 7 816
一整个雨季
一整个雨季 2020-12-06 06:24
package com.valami;

 public class Ferrari
 {
  private int v = 0;


  private void alam()
  {
   System.out.println(\"alam\");
  }

  public Ferrari()
  {
   System         


        
7条回答
  •  一整个雨季
    2020-12-06 07:10

    Well, main() is part of the containing class. In fact, main() is exactly like every other method, except that you can start the JVM and tell it to run the main() method of a class from the command line.

提交回复
热议问题