Java examples for Language Basics:String
Format with String.format method
public class Main { public static String someMethod(int[] array2, int x) {/*from w ww . j a v a 2 s. c o m*/ if (x < array2.length) return String.format( "%s%d ", someMethod(array2, x + 1), array2[x]); else return ""; } public static void main(String[] args) { int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; String results = someMethod(array, 0); System.out.println(results); } }