要确保authService中的isLoggedIn值始终为true,可以采取以下解决方法:
public class AuthService {
public static boolean isLoggedIn = true;
}
public class AuthService {
private static boolean isLoggedIn = true;
public static void setLoggedIn() {
isLoggedIn = true;
}
}
public class AuthService {
private static AuthService instance;
private boolean isLoggedIn;
private AuthService() {
isLoggedIn = true;
}
public static AuthService getInstance() {
if (instance == null) {
instance = new AuthService();
}
return instance;
}
public boolean isLoggedIn() {
return isLoggedIn;
}
}
使用上述方法之一,可以确保authService中的isLoggedIn始终为true。请根据你的具体需求选择适合的解决方法。