import java.util.Random;
public class Lin
{private int data[];
private Random generator = new Random();
public Lin(int size)
{
data=new int[size];
for (int i = 0; i<size; i++)
data[i]=generator.nextInt(90);
}
public int SearchLinear(int searchKey)
{ int index;
for (index = 0; index<data.length; index++);
if(data[index]==searchKey)
return index;
return -1;
}
}
// then when I Call that Class in Another class As following TestApplication It tells me (Symbol cannot be find) and gives me Error!!
import java.util.Scanner;
public class TestApplication
{
public static void main (String[] args)
{// My problem is in here it Cannot find Symbol Lin which is The class name of privouse class..!!
Lin Arr = new Lin();
System.out.print(Arr);
Scanner input = new Scanner(System.in);
int searchint;
int Position;
System.out.println ("please enter an integer to search or -1 to exit");
searchint=input.nextInt();
while (searchint!=-1)
{
Position=Arr.SearchLinear(searchint);
if (Position==-1)
System.out.println ("the Integer You were looking for wasnot find");
else
System.out.println ("the intger You were looking is in index "+Position);
}
}
}
This post has been edited by macosxnerd101: 27 May 2011 - 10:18 AM
Reason for edit:: Title renamed to be more descriptive.

New Topic/Question
Reply




MultiQuote






|