Why can I access a private variable from main method?

后端 未结 7 835
一整个雨季
一整个雨季 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:06

    The only special feature of the main method is it is used to tell the compiler where program execution should begin. Other than that it behaves just like any other class method and has access to private variables like any other class method.

提交回复
热议问题