public class Test{ public static void main(String args[]){ StringBuffer sBuffer = new StringBuffer("菜鸟教程官网:"); sBuffer.append("www"); sBuffer.append(".runoob"); sBuffer.append(".com"); System.out.println(sBuffer); } }
public class TestArray { public static void main (String [] args) { // array size int size = 10 ; // definition array Double [] myList = new new Double [size]; myList [ 0] = 5.6 ; myList [ . 1] 4.5 of 5 = ; myList [ 2] = 3.3 ; myList [ . 3] = 13.2 ; myList [ . 4] = 4.0 ; myList [ . 5] = 34.33 ; myList [ . 6] = 34.0 ; myList [. 7] = 45.45 ; myList [ . 8] = 99.993 ; myList [ . 9] = 11123 ; // calculate all elements in the sum Double Total = 0 ; for ( int I = 0; I <size; I ++ ) { Total + = myList [ I]; } System.out.println ( "sum:" + Total); } }
public class TestArray { public static void main (String [] args) { Double [] myList = {1.9, 2.9, 3.4, 3.5 of }; // print all the array elements for ( int I = 0; I <myList.length; I ++ ) { System.out.println (myList [I] + "" ); } // calculating the sum of all the elements Double Total = 0 ; for ( int I = 0; I <myList.length; I ++ ) { Total + = myList [I]; } System.out.println ( "IS the Total" + total); // 查找最大元素 double max = myList[0]; for (int i = 1; i < myList.length; i++) { if (myList[i] > max) max = myList[i]; } System.out.println("Max is " + max); } }
public class TestArray { public static void main (String [] args) { Double [] myList = {1.9, 2.9, 3.4, 3.5 of }; // print all the array elements for ( Double Element: myList) { System.out.println ( Element); } } }
public static void printArray(int[] array) { for (int i = 0; i < array.length; i++) { System.out.print(array[i] + " "); } }
public static int[] reverse(int[] list) { int[] result = new int[list.length]; for (int i = 0, j = result.length - 1; i < list.length; i++, j--) { result[j] = list[i]; } return result; }
String s[][] = new String[2][]; s[0] = new String[2]; s[1] = new String[3]; s[0][0] = new String("Good"); s[0][1] = new String("Luck"); s[1][0] = new String("to"); s[1][1] = new String("you"); s[1][2] = new String("!");