Skip to content
This repository was archived by the owner on Mar 17, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ Start adding your names here:
- I like AI, programming and web development.
- [![github-alt][github-img]](https://github.com/kundan28)

### Saideep Dicholkar
- I love technology
- I like watching tech videos on YouTube
- I like Web Development and building Android Apps
- [![github-alt][github-img]](https://github.com/saideepd)
[![twitter-alt][twitter-img]](https://twitter.com/saidicholkar)
[![google-img][google-img]](https://plus.google.com/+SAIDEEPDICHOLKAR)

### Example Profile
- I'm an example that you can copy, if you want :)
- I work for...
Expand Down
40 changes: 40 additions & 0 deletions code/saideep.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Sorting and Searching in Array
// Sorting using Java Collection's Sort method
import java.util.*;
class saideep {
public static void main(String args[]) {
boolean flag = false;
int i = 0;
Scanner scan = new Scanner(System.in);
System.out.print("Hello World!");
System.out.print("\n\nEnter the number of elements: ");
int n = scan.nextInt();
int arr[] = new int[n];
System.out.println("Enter array elements: ");
for(i = 0; i < n; i++) {
arr[i] = scan.nextInt();
}
System.out.println("\nArray before sorting: ");
for(i = 0; i < n; i++) {
System.out.print(" "+arr[i]);
}
System.out.println("\n");
System.out.println("Array after sorting: ");
Arrays.sort(arr);
for(i = 0; i < n; i++) {
System.out.print(" "+arr[i]);
}
System.out.println("\n\nEnter no. to search: ");
int no = scan.nextInt();
for(i = 0; i < n; i++) {
if(arr[i] == no) {
flag = true;
break;
}
}
if(flag)
System.out.println("\n" + no + " found at position "+(i+1));
else
System.out.println("\n" + no + " not found in the array");
}
}