-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraysClass.java
More file actions
27 lines (22 loc) · 895 Bytes
/
Copy pathArraysClass.java
File metadata and controls
27 lines (22 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.example;
import java.lang.reflect.Array;
import java.util.Arrays;
public class ArraysClass {
public static void main(String args[]){
int[] arr = {2,5,7,2,1,9,5,9,23,12,56,34,45,22,11,20};
//In sort method parallelSort is more efficient to sort
Arrays.parallelSort(arr,3,9);
for(int i = 0 ; i < arr.length ; i++)
System.out.print(arr[i] + " ");
System.out.println();
Arrays.sort(arr);
for(int i = 0 ; i < arr.length ; i++)
System.out.print(arr[i] + " ");
//binarySearch method serach elements and return index
System.out.println("\n" + arr[Arrays.binarySearch(arr,23)] + " Index is " + Arrays.binarySearch(arr,23));
//use to same elements in array fill method
Arrays.fill(arr,1,10,5);
//toString method its return string to represent array of all elements
// its use to travasing more efficient to converted String
}
}