import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
System.out.println("--- 1 ---");
f(null); // --> warning
f((String) null);
f((String[]) null);
System.out.println("--- 2 ---");
String s = null;
f(s == null ? null : new String[] { s });
s = "hello, world";
f(s == null ? null : new String[] { s });
System.out.println("--- 3 ---");
f();
f("hello");
f("hello", "world");
System.out.println("--- 4 ---");
f(new String[0]);
f(new String[] { "hello" });
f(new String[] { "hello", "world" });
}
public static void f(String... s) {
System.out.println(s == null ? "null" : (s.length + ", " + toString(s)));
}
private static String toString(String[] a) {
String s = "[";
for (int i = 0; i < a.length; i += 1) {
s += a[i] == null ? "null" : ("'" + a[i] + "'");
if (i < a.length - 1) {
s += ", ";
}
}
s += "]";
return s;
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: