Hey friends,
I am stuck in this the program below.
I am supposed to get the result of the item whether it's in array of not. Kindly guide me through this...where I have done the mistake.
I am new in Java.
__________________________________________________ _____________________
class LinearSearching
{
public static void main(String[] args)
{
int data[] = {11,23,54,34,44,76};
int n = data.length;
int item = 50;
int loc = 0;
data[n+1] = item;
do
{
loc = loc + 1;
}
while(data[loc]!=item);
if(loc == n+1)
{
loc = 0;
System.out.println("Unsuccessful");
}
else
System.out.println("Successful");
}
}
__________________________________________________ ______________________