正在加载图片...
Chapter 11: Collections of Objects result. append( "]")i eturn result. tostring( public static string tostring (int[] a)i StringBuffer result new StringBuffer("[")i for (int i = 0; i<alength; i++) result. append(a [i])i if (i a length -1 result. append(,)i result. append("]") return result. tostring( )i public static String tostring (long[] a)( StringBuffer result new StringBuffer("[") for(int i =0; i<a length; i++)t result. append(a[i]) if(i a length -1) result. append(",")i result return result. tostring( )i public static String tostring(float[ a) StringBuffer result new StringBuffer("[") for(int i =0; i<a length; 1++) (a[i]); if (i alength -1 result. append(,)i result. append("]")i public static string tostring(double [] a) StringBuffer result new String Buffer("[")i for (int i =0; i<alength; 1++) result. append(a[i])i f(i< al 1) (","); result. append("]") // Fill an array using a generator: public static void fill(object a.⊥eng public static void fill(object[] a, int from, int to, Generator gen for (int i = from; i< a lil public static void fill(boolean[ a, BooleanGenerator gen) t blic static void 第10页共106页 wgqqh. com/shhgs/tij. htmlChapter 11: Collections of Objects 第 10 页 共 106 页 www.wgqqh.com/shhgs/tij.html email:shhgs@sohu.com result.append("]"); return result.toString( ); } public static String toString(int[] a) { StringBuffer result = new StringBuffer("["); for(int i = 0; i < a.length; i++) { result.append(a[i]); if(i < a.length - 1) result.append(", "); } result.append("]"); return result.toString( ); } public static String toString(long[] a) { StringBuffer result = new StringBuffer("["); for(int i = 0; i < a.length; i++) { result.append(a[i]); if(i < a.length - 1) result.append(", "); } result.append("]"); return result.toString( ); } public static String toString(float[] a) { StringBuffer result = new StringBuffer("["); for(int i = 0; i < a.length; i++) { result.append(a[i]); if(i < a.length - 1) result.append(", "); } result.append("]"); return result.toString( ); } public static String toString(double[] a) { StringBuffer result = new StringBuffer("["); for(int i = 0; i < a.length; i++) { result.append(a[i]); if(i < a.length - 1) result.append(", "); } result.append("]"); return result.toString( ); } // Fill an array using a generator: public static void fill(Object[] a, Generator gen) { fill(a, 0, a.length, gen); } public static void fill(Object[] a, int from, int to, Generator gen) { for(int i = from; i < to; i++) a[i] = gen.next( ); } public static void fill(boolean[] a, BooleanGenerator gen) { fill(a, 0, a.length, gen); } public static void
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有