簡體   English   中英

從同一目錄中的另一個 class 訪問公共 class 變量

[英]Accessing the public class variable from another class in same directory

我遇到了一個 java 代碼,其中公共 class 實用程序的方法aw_best_tour_index()訪問 class InOut的變量是public的。 class InOut的變量是best_in_trymax_index 他們在這樣的方法中被調用:

final int[] values = InOut.best_in_try;

final int l = InOut.maxindex; .

但是當我在命令提示符下使用 javac 編譯它時,它會顯示錯誤“找不到符號”。 這應該是什么原因?

可能有多個問題:

  • 如果 InOut 不在同一個 Java 文件中,您是否包括在內
  • 變量是 static
  • 如果不是,InOut 是否是包含 maxindex 和 best_in_try 的 class 的實例?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM