I love the String class!
- Co pojawi się na ekranie po uruchomieniu poniższego kodu?
public class LovelyStrings {
public static void main(String[] args) {
String[] words = {"I ", "love ", "the ", "String ", "class!"};
String statement = null;
for (String word : words) {
statement += word;
}
System.out.println(statement);
}
}
Odpowiedzi:
(a) nic się nie pojawi
(b) „I love the String class!”
(c) wyjątek podczas uruchomienia (NullPointerException)
(d) żadne z powyższych
- Odpowiedź uzasadnij i wyjaśnij dlaczego tak to działa