1
Я пытался это ...Android, не удалось установить свойство статического геттера?
public class Info {
private static Info ourInstance = new Info();
public static Info getInstance() { return ourInstance; }
private static int currentIndex;
public static void setCurrentIndex(int i) {
Log.d("DEV", "setter!");
currentIndex = i;
// do other work here
}
public static int getCurrentIndex() {
Log.d("DEV", "getter!");
return currentIndex;
}
private Info() {
Log.d("DEV", "class initialized no problem...");
currentIndex = 42; // just doesn't work, only sets the field
}
}
в любом другом классе ...
Info.currentIndex = 666; // just doesn't work
Это просто не работает - что может быть проблема? Пробовал все.
свят - Я совершенно забыл, что Java Безразлично 'дайте вам магический доступ к геттерам/сеттерам. Извините за потраченное время !!!!!!!!!!!!!!!!!!!! благодаря!!!!!!!!! – Fattie
без проблем @ JoeBlow, добро пожаловать –