I have a class called
public class UserSettings {
public static String sessionId;
public static int vrefresh;
public static int mrefresh;
}
Then in another class I have this method
public static void parseBusinessObject(String input, Object output)
And this method writes into the output Object.
But in this case there are still static variables, so I can pass the class without creating an object?
You don’t need to pass the class at all, you can write directory to the static property:
Whether or not you should is a different issue. If you’re passing a
UserSettingsas theObjectparameter (unclear from your post) you can access static members through the instance reference:This is considered… sub-optimal: Java conventions access static properties through the class only, not instances, despite the syntactic legality of doing so. But your method takes an
Object, so you’d need to use reflection or casting based oninstanceOfresults–I’m suspicious of the method itself.