Академический Документы
Профессиональный Документы
Культура Документы
Array class
Instance variable is getting its memory from instance of a class. which means heap
memory of JVM.
Class variable is getting memory from method area of JVM.
Local Variable gets memory from stack.
int arr[]={1,2,5,7,5};
b) Arrays.binarySearch(arr,num);
If the num is present, it prints the first location (zero based)
1,2,5,5,7
5
2
If the num is not present, it prints its position where it could be present(one
based) with a -ve sign.
1,2,5,5,7
4
-3
When we compard the md3.arr and b arrays using .equals() method, it printed true.
This is becoz both have identical contents.
e)Arrays.equals()
WAP to accept an array input from user and print the sum of second largest and
second smallest element in the array.
Sample Input
8
2 5 2 1 2 5 8 4
Sample Output
7