For those saying that the code is too verbose, here is another version in Common Lisp:
(defun jim (arg &optional path)
(etypecase arg
(string
(format t "import ~{~(~A~).~}~A;~%" (reverse path) arg))
(list
(push (pop arg) path)
(dolist (a arg)
(jim a path)))))
Test: (jim
'(java
(util "HashMap" "HashSet" "Map" "Random" "Set" "UUID"
(concurrent "ExecutorService" "Executors" "Callable" "Future"))
(awt "Color")))
Gives: import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.awt.Color;
If you'd prefer common lisp you should check out the project that inspired mine: https://github.com/zc1036/lips