44. Array operations. class ArrayOperations { public stat | Advance Java 👨💻
44. Array operations.
class ArrayOperations { public static void main(String[] args) { double[] myList = {1.9, 2.9, 3.4, 3.5};
// Print all the array elements for (int i = 0; i < myList.length; i++) { System.out.println(myList[i] + " "); } // Summing all elements double total = 0; for (int i = 0; i < myList.length; i++) { total += myList[i]; }
System.out.println("Total is " + total);
// Finding the largest element double max = myList[0]; for (int i = 1; i < myList.length; i++) { if (myList[i] > max) max = myList[i]; }
This channel will serve you all the Codes and Programs of java Programming Language. Contact Admin: @Pravin_Suthar . Youtube channel: . https://www.youtube.com/channel/UCWFwwPMuAx_DY3hi9Tin7gA. Like s...