Мой вариант кода:
static {
if (president == null) {
synchronized (OurPresident.class) {
if (president == null) {
president = new OurPresident();
}
}
}
}
Почему валидатор может не пропускать?package com.javarush.task.task17.task1706;
/*
Синхронизированный президент
*/
public class Solution {
public static void main(String[] args) {
OurPresident expectedPresident = OurPresident.getOurPresident();
OurPresident ourPresident = OurPresident.getOurPresident();
System.out.println(expectedPresident == ourPresident);
}
}