Results 1 to 7 of 7
Thread: Help! 1 error...
- 03-30-2010, 02:56 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 3
- Rep Power
- 0
Help! 1 error...
import java.util.Arrays;
import java.util .Scanner;
/**
This program demonstrates the linear search algorithm.
*/
public class LinearSearcherTest
{
public static void main(String[] args)
{
int[] a = ArrayUtil.randomIntArray(20, 100);
System.out.println(Arrays.toString (a));
LinearSearcher searcher = new LinearSearcher(a);
Scanner in = new Scanner(System.in);
boolean done = false;
while (!done)
{
System.out.print("Enter number to search for, -1 to quit: ");
int n = in.nextInt();
if (n == -1)
done = true;
else
{
int pos = searcher.search(n);
System.out. println("Foundinposition" + pos);
}
}
}
}
cannot find symbol
symbol : variable ArrayUtil
location: class LinearSearcherTest
int[] a = ArrayUtil.randomIntArray(20, 100);
^
1 error
- 03-30-2010, 03:02 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
- 03-30-2010, 03:05 PM #3
Hmm I'd use other words than the compiler, but that class is not part of the SE API.
EDIT: What Jos said.Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 03-30-2010, 04:01 PM #4
Member
- Join Date
- Mar 2010
- Posts
- 3
- Rep Power
- 0
I have this to go with it aswel, its just soooo confusing :S
/**
A class for executing linear searches through an array.
*/
public class LinearSearcher
{
/**
Constructs the LinearSearcher.
@param anArray an array of integers
*/
public LinearSearcher(int[] anArray)
{
a = anArray;
}
/**
Finds a value in an array, using the linear search
algorithm.
@param v the value to search
@return the index at which the value occurs, or -1
if it does not occur in the array
*/
public int search(int v)
{
for (int i = 0; i < a.length; i++)
{
if (a[i] == v)
return i ;
}
return -1;
}
private int[] a;
}
- 03-30-2010, 04:22 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
- 03-30-2010, 06:30 PM #6
Member
- Join Date
- Mar 2010
- Posts
- 3
- Rep Power
- 0
yeah my friend and I wrote it, I have a very basic understanding of Java always seem to make mistakes!
- 03-30-2010, 06:46 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
> Operator cannot be applied error and return incompatible types error
By corney_16 in forum New To JavaReplies: 1Last Post: 03-10-2010, 01:53 PM -
Thread: Error 500--Internal Server Error java.lang.NullPointerException
By jackdear44 in forum New To JavaReplies: 1Last Post: 12-05-2009, 07:28 AM -
java.lang.Error: Error opening DSound for capture
By NARs in forum NetworkingReplies: 1Last Post: 10-26-2009, 04:38 PM -
Diference Between compiler error Garbage collection and Runtime Error?
By makpandian in forum New To JavaReplies: 3Last Post: 01-23-2009, 08:53 AM -
error 530 error authentication required
By rgale in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 05-12-2008, 04:28 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks