import java.util.Arrays; public class ArrayDemo { public static void main(String[] args) { // initializing unsorted char array char charArr[] = {'a', 'c', 'b', 'e','d'}; // sorting array Arrays.sort(charArr); // let us print all the elements available in list System.out.println("The sorted char array is:"); for (char number : charArr) { System.out.println("Number = " + number); } // entering the value to be searched char searchVal = 'e'; int retVal = Arrays.binarySearch(charArr, searchVal); System.out.println("The index of e is : " + retVal); } }
this site is to help students to learn coding in java platform and qbasic platform. all programs are ICSE and ISC level. Java programs java python Python programs
Character search in Character Array Using Binary Search
Subscribe to:
Posts (Atom)
Second largest number in java using ternary operator
//Largest second number using ternary operator public class Main { public static void main(String[] args) { int a=5,b=6,c=7; int ...
-
import java.util.*; class riwi { public static void main(String[]args) { Scanner sc=new Scanner(System.in); System...
-
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 28 29 30 31 32 33 34 35 36 37 ...
-
import java.io.*; class snowball { public static void main()throws IOException { BufferedReader br = new BufferedReader(new InputStreamRead...