I'm new to programming and I'm quite confused why some people are insisting that global variables are bad. I'm currently writing a program with several classes and a lot of checking and rewriting data stored in variables. I found global variables extremely helpful since I don't need to create a getter and setter for each of the local or possibly class variables. By using global variables as bridges between different classes, I found it surprisingly easy to exchange information between those classes.
But again, I'm quite new to programming and I would be much appreciated if someone could explain to me why this is not advisable to do.
Edit: My apologies! I didn't know that global variables and public class variables are completely different and apparently I misidentified public fields as global variables. You never know how silly of a mistake a beginner programmer can make Lol. Thanks everyone for bringing this to my attention.