简体   繁体   中英

Accessing the public class variable from another class in same directory

I've come across a java code in which the method aw_best_tour_index() of public class Utilities access the variable of the class InOut which is public . The variables of the class InOut are best_in_try and max_index . They've been called in the method like this:

final int[] values = InOut.best_in_try; and

final int l = InOut.maxindex; .

But when I compile this using javac in command prompt it shows the error "Cannot find symbol". What should be reason for this?

There could be multiple problems:

  • Did you include InOut if it isn't in the same Java file
  • Are the variables static
  • If not, is InOut an instance of the class containing maxindex and best_in_try?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM