How do I create a "global variable" in Java such that all classes can access it?

Posted by Chrystle Soh on Stack Overflow See other posts from Stack Overflow or by Chrystle Soh
Published on 2013-11-12T20:59:15Z Indexed on 2013/11/12 21:54 UTC
Read the original article Hit count: 153

Filed under:

here's my problem: I have multiple classes that are part of the same package and they need access to a certain file path

String filePath = "D:/Users/Mine/School/Java/CZ2002_Assignment/src/"

Rather than declaring the same Filepath in every single class, is it possible to simply have a "global" type of variable of this FilePath so that all classes can access it and I only need to declare and update it once.

Thanks

© Stack Overflow or respective owner

Related posts about java