/**
* {@link <a href=
* "https://[Log in to view URL]"
* target="_blank">Allocazione statica e dinamica di un array</a>}
*
* @author itammb ( Italia Massimiliano Buscati )
* @version JDK 1.15
*
*/
class Main {
public static void assignement() {
String[] words = { "ITAitp", "[", "Italy Italo Persechino", "]" };
printIndex(words);
}
/**
* @see String#split(String regex)
*
*/
public static void splitText() {
String text = new String("ITAitp [ Italy Italo Persechino ]");
String[] words = text.split(" ");
printStream(words);
}
private static void printStream(String[] words) {
for (String word : words)
System.out.println(word);
}
private static void printIndex(String[] words) {
for (int i = 0; i < words.length; i++)
System.out.println(words[i]);
}
public static void main(String[] args) {
// Unit test - allocazione statica di un array durante la compilazione
assignement();
System.out.println();
// Unit test - allocazione dinamica di un array in fase di run-time
splitText();
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: