here is a super simplified answer, if you want more details just add a comment ;)
class SomeVariables{
String s;
int dontneed;
}
class MainClass{
// this is ok
SomeVariables vars= new SomeVariables();
// not allowed here, must be on method, main for example
vars.s = "why this doesnt work?. IDE says Uknown class 'vars.s'";
// not allowed here, must be on method, main for example
System.out.println(vars.s); // Accesing it also doesnt work
void ChangeValue(){
// it works because is on scope and inside a method
vars.s = "why does this work?";
}
public static void main(String[]args){
// here sholud be your statements var.s = ... and System.out.println
}
}