im actually pretty new into java , my homework was to create a array . After a while of searching for a good video i found this .
--
If i compile this blue j shows me that "int 1=0;" is not a statement .
Can someone tell me where the mistake is ?
Thanks for helping
import java.util.*;
class binarysearch
{
public static void main ()
{
Scanner sc= new Scanner (System.in);
int num[]= new int [] {23,34,45,56,67,78,89,90,12};
System.out.println("Enter the Number to search");
int n=sc.nextInt();
int u=num.length-1,mid=0;
int 1=0;
int c=0;
while(1<=u)
{
mid=(1+u)/2;
if(n<num[mid])
u=mid-1;
if(n>num[mid])
1=mid+1;
if(n==num[mid])
{
c=1;
break;
}
}
if(c==1)
System.out.println("search successful"+"\n"+"this number " +n+ "position" +(mid+1));
else
System.out.println("Number not found");
}
}