본문 바로가기

Passing String Array Parameter

java by 낼스 2014. 12. 5.

public class StringArrayParameter {
	public static void main(String[] args) {
        String[] strArray = new String[]{"Foo","Bar","Baz"};		
        stringConcat (strArray);
        Integer[] intArray = new Integer[]{1,2,3};		
        integerConcat (intArray);
	}

	static void stringConcat (String ... strings)
	{
		StringBuilder sb = new StringBuilder ();
		for (int i = 0; i < strings.length; i++)
			sb.append (strings [i]);
		System.out.println(sb.toString());
	}	
	
	static void integerConcat (Integer ... ints)
	{
		StringBuilder sb = new StringBuilder ();
		for (int i = 0; i < ints.length; i++)
			sb.append (ints [i]);
		System.out.println(sb.toString());
	}	
}


댓글