class Main {
public static void main(String[] args) {
// System.out.println("Hello world!");
// int[]array = new int[4];
// System.out.println(array == null);
int n = 10;
int[] arr =new int[n];
for (int i = 0; i < n; i++){
arr = i *10;
}
System.out.println(arr[9]);
}
}
package com.laioffer.classone;
public class MyFirstClss { public static void main(String[] args) { int[] arr = {2, 13, 5, 6, 7}; int max = arr[0]; for (int i = 1; i < arr.length; i++) {// i = index and could set any index i = 0 or 1 or 2 if(arr > max) { max = arr; } }System.out.println(max); } } public class MyFirstClss { public static void main(String[] args) { int [] arr = {2, 13, 5, 6, 7}; int max = Integer.MIN_VALUE;//
for (int i : arr) {// element; from the first element to : arr[-1] if (max < i) { max = i; } } System.out.println(max); } } |