✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
// import ALL useful classes
import java.util.*;
class lamp {
int static count = 0;
public int id;
public static List<lamp> Lamps = new ArrayList<lamp>();
public lamp() {
if (Lamps.size() >= 10) {
throw new NullPointerException("It is impossible to have more than 10 lamps!");
}
// give every instance an unique id
this.id = count++;
Lamps.add(this);
}
public List<lamp> getLamps() {
// ensure user cannot change this list
return Collections.unmodifiableList(Lamps);
}
public static void main(String[] args) {
while (true) {
lamp m = new lamp();
System.out.println(m.id);
}}}
Mille vastu on koodi kirjutamisel eksitud (vali 5)?
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!