| | |
Linear Search
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2004
Posts: 2
Reputation:
Solved Threads: 0
Hi this is Salman.I am having a problem is linear search.The program doesnt compile giving the error "No method found matching linsearch".My code is
class search{
public static void main(String args[]){
int A[]=new int[1000];
for(int i=0;i<A.length;i++){
A[i]=(int) (1000*Math.random() +1);
System.out.println(linSearch(799, A[i]));
}
}
}
class searching{
public static int linSearch (int target, int [] list)
{
int location = -1, i = 0;
boolean found = false;
while (!found && i < list.length)
{
if (list [i] == target)
found = true;
else
i++;
}
if (found)
{
location = i;
}
return location;
}
}
Please tell me what to do
class search{
public static void main(String args[]){
int A[]=new int[1000];
for(int i=0;i<A.length;i++){
A[i]=(int) (1000*Math.random() +1);
System.out.println(linSearch(799, A[i]));
}
}
}
class searching{
public static int linSearch (int target, int [] list)
{
int location = -1, i = 0;
boolean found = false;
while (!found && i < list.length)
{
if (list [i] == target)
found = true;
else
i++;
}
if (found)
{
location = i;
}
return location;
}
}
Please tell me what to do
![]() |
Similar Threads
- Linear Search - pascal HELP! (Pascal and Delphi)
- Code Snippet: Linear search (C++)
- Fastest way to search the table ( or array ) (C++)
- C++ 6. Search Benchmarks. (C++)
- Linear search (C++)
Other Threads in the Java Forum
- Previous Thread: If Else Loops
- Next Thread: writting screen saver program using J2ME
| Thread Tools | Search this Thread |
Tag cloud for Java
affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth businessintelligence chat class classes client code component database desktop draw ebook eclipse encode equation error event exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer intersect j2me java javaexcel javaprojects jmf jni jpanel julia linked linux list loop mac main map method methods mobile netbeans newbie number object online open-source oracle parameter print problem program programming project properties recursion reference replaysolutions rotatetext scanner score screen scrollbar server set size sms socket sort sql string superclass swing template test threads time tree windows xstream





