public class ArrayDemo
{
public static void main(String args[])
{
int arr[] = {2, 4, 5, 7, 9, 10};
for(int i = 0; i < arr.length; i++)
{
System.out.println("arr["+i+"] = "+arr[i]);
}
}
}
public class MaxMinDemo
{
static void max(int arr[])
{
int max = arr[0];
for( int i = 1; i < arr.length; ++i)
{
if(arr[i] > max)
max = arr[i];
}
System.out.println("Max value is: "+max);
}
static void min(int arr[])
{
int min = arr[0];
for( int i = 1; i < arr.length; ++i)
{
if(arr[i] < min)
min = arr[i];
}
System.out.println("Min value is: "+min);
}
public static void main(String args[])
{
int arr[] = {10, 2, 7 , 3, 16, 21, 9};
max(arr);
min(arr);
}
}
public class ForEachDemo
{
public static void main(String[] args)
{
int[] arr = {3, 5, 7, 11, 13, 17};
for (int element: arr)
{
System.out.print(element+" ");
}
}
}
public class MultiDimeDemo
{
public static void main(String args[])
{
int arr[] [] = {{9,8,7},{6,5,4},{3,2,1}};
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 3; j++)
{
System.out.print(arr[i][j]+" ");
}
System.out.println();
}
}
}
public class ArrayCopyDemo
{
public static void main(String[] args)
{
char[] source = { 'a', 'T', 'u', 't', 'o', 'r', 'i', 'a', 'l', 'R','i', 'd', 'e' };
char[] dest = new char[12];
System.arraycopy(source, 1, dest, 0, 12 );
System.out.println(new String(dest));
}
}