 Hello friends, I am Sanjay Gupta. In this video I am going to demonstrate you how you can perform linear search in Java. So first time creating a class whose name is linear search, inside this class I am going to define definition of main function. In this main function I am going to implement the code which will perform linear search in Bundy array. First time declaring instance of scanner class. For this scanner class I am going to import a package name is utl and its class scanner. Scanner is predefined class that's why we have to import this utl package and through utl package you can import scanner class and you can use it in your program. Now I am declaring an array of variable n, variable f and i. Now I am going to display a message enter size of array. Entered size will be stored inside n variable. So now I am going to allocate memory for this array. So this way I have dynamically created array in Java. Now I am going to receive values for this array from user. So again system.out.penter and the message will be enter elements. So user has to enter n number of elements for reading n numbers and rotating a loop. This loop will repeat n times and the entered number will be stored inside array using this input dot next int method. This way I have received all the elements for array now. Again I am implementing system.out.println which will display enter the number you want to search. So we have to search a particular number whether it is available in array or not that is linear search. So I have to receive that number to store that number and again declaring a variable num. So statement is num equals to input dot next int. So this way I have received three different type of values from user. First one is size of array. Second one all elements of array and third one is the number which user want to search whether it is available in array or not. Now I can apply a loop. It will repeat n times and this loop will check whether num is available in array or not. Condition is ARRI double equals to num. So I am going to compare num with ARRI if this condition is true. It means number is available inside array. So you can see I have declared a variable f at line number eight which is initialized with zero. So f belongs to found or not found. So if this condition is true then I can assign one into f and I am going to break this loop because if number is found then there is no need to repeat the loop because if number is found at a particular position it means number is available in the array and value of f will become one. So after completion of this loop we have to check value of f whether it is one or zero. So if f is one it means number is present so system.out.println we can print a particular message number is present or this message can be anything else number is not present. So this way through this if condition I have checked the value of f variable accordingly the result will be displayed on output screen. So this way I have implemented the linear search method in Java. Now I am going to execute this code so that you can understand how it will work. So I am going to derive inside Java folder. I have saved this program with linear search dot Java. You can see it here at the top of notepad file. So first I have to compile this code. You can see it is compiled successfully because it is not showing any kind of error. Now I can easily execute this code searching that file. I am again executing this code. So you can see now it is executing properly. I forward to save the code. I have entered size as five. Now I am going to enter five elements. Now it is asking enter number you want to search. So I am entering six. You can see the output. It is showing number is present. Again I am executing this code. This time I am entering sizes for numbers are 2345 and I am going to search eight. You can see it is showing number is not present. So this way you can see the program is working properly in both the conditions. Whether number is available or not available. So I hope you have understood how we can perform linear search in Java. Thank you for watching this video.