Hi,
can anyone help out here????
I have the below error after compling the file. Any idea what is wrong in the declaration that was done in the above code??? Appreciate any help on shedding some light for this error on how to rectify it.
C:\Documents and Settings\wei cheng\Desktop\a a1\test.java:12 2: cannot find symbol
symbol : method objCompare(java .lang.Object,Pe rson)
location: class test
if (objCompare(inp utArr.get(i), p1) == 0)
^
C:\Documents and Settings\wei cheng\Desktop\a a1\test.java:13 0: cannot find symbol
symbol : method objCompare(java .lang.Object,Pe rson)
location: class test
if (objCompare(inp utArr.get(i), p1) == 0)
This is the source code and for your info they are all in the same file:
StringTokenizer st = new StringTokenizer (surName);
surName = st.nextToken();
Person p1 = new Person(surName, "", 0);
// do the search search
System.out.prin tln("********** *****binary Search********* *********");
int result = LibraryComparat or.binarySearch (inputArr, p1, new objCompare());
System.out.prin tln(surName + " " + result);
if (result != -1)
{
GenericSimpleAr rayList outputArr = new GenericSimpleAr rayList();
//search 1st element of input array that matches
for (int i=result; i>=0; i--)
{
if (objCompare(inp utArr.get(i), p1) == 0) {
outputArr.add(i nputArr.get(i)) ;
}
}
//search for other element of input array that matches
for (int i=result+1; i<inputArr.size (); i++)
{
if (objCompare(inp utArr.get(i), p1) == 0) {
outputArr.add(i nputArr.get(i)) ;
}
}
public static class objCompare<AnyT ype extends Comparable<? super AnyType>> implements Comparator<Pers on>
{
public int compare(Person lhs, Person rhs)
{
return lhs.surName.toL owerCase().comp areTo (rhs.surName.to LowerCase());
}
}
can anyone help out here????
I have the below error after compling the file. Any idea what is wrong in the declaration that was done in the above code??? Appreciate any help on shedding some light for this error on how to rectify it.
C:\Documents and Settings\wei cheng\Desktop\a a1\test.java:12 2: cannot find symbol
symbol : method objCompare(java .lang.Object,Pe rson)
location: class test
if (objCompare(inp utArr.get(i), p1) == 0)
^
C:\Documents and Settings\wei cheng\Desktop\a a1\test.java:13 0: cannot find symbol
symbol : method objCompare(java .lang.Object,Pe rson)
location: class test
if (objCompare(inp utArr.get(i), p1) == 0)
This is the source code and for your info they are all in the same file:
StringTokenizer st = new StringTokenizer (surName);
surName = st.nextToken();
Person p1 = new Person(surName, "", 0);
// do the search search
System.out.prin tln("********** *****binary Search********* *********");
int result = LibraryComparat or.binarySearch (inputArr, p1, new objCompare());
System.out.prin tln(surName + " " + result);
if (result != -1)
{
GenericSimpleAr rayList outputArr = new GenericSimpleAr rayList();
//search 1st element of input array that matches
for (int i=result; i>=0; i--)
{
if (objCompare(inp utArr.get(i), p1) == 0) {
outputArr.add(i nputArr.get(i)) ;
}
}
//search for other element of input array that matches
for (int i=result+1; i<inputArr.size (); i++)
{
if (objCompare(inp utArr.get(i), p1) == 0) {
outputArr.add(i nputArr.get(i)) ;
}
}
public static class objCompare<AnyT ype extends Comparable<? super AnyType>> implements Comparator<Pers on>
{
public int compare(Person lhs, Person rhs)
{
return lhs.surName.toL owerCase().comp areTo (rhs.surName.to LowerCase());
}
}
Comment