diff --git a/searching/README.md b/searching/README.md index b9f2ef6d..324b67bb 100644 --- a/searching/README.md +++ b/searching/README.md @@ -15,3 +15,8 @@ 1. [Linear Search](js/linear-search.js) +### Java + +1. [Linear Search](java/linear-search.java) + + diff --git a/searching/java/linear-search.java b/searching/java/linear-search.java new file mode 100644 index 00000000..4c8e2d3b --- /dev/null +++ b/searching/java/linear-search.java @@ -0,0 +1,21 @@ +//Linear search to check for a given key in an array + +public class MyLinearSearch{ +public static int linearSearch(int[] arr, int key){ + for(int i=0;i followed by +//It will generate and a MyLinearSearch.class file which is a file containing java bytecode that is executed by JVM.