Hi-
I'd like to use this class from a book but am getting a compiler error.
On the line
private List < String > list; p.932 Chapter 19
found in the code below in the eclipse editor it is underlined
in red. It is saying it is a syntax error and to delete the tokens.
I'd like to use the code below in my program i am working on for my hobby.
It will make life so much easier when i get past the compiler error.
thanks for any help,
jim
package calcpackage;
import java.util.List;
import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
/**
* @author HP_Owner
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class FieldCalculations {
private static final String colors[]={"red","green","blue"};
private List < String > list; // ***************compiler generates error on
this line*********
public SearchTest()
{
list=new ArrayList<String>(Arrays.asList(colors));
Collections.sort(list);
}
private void search()
{
getIndex("green");
}
private int getIndex(String key)
{
int result=0;
result=Collections.binarySearch(list,key);
if(result >=0)
return result;
else
System.out.println("error not found "+ result);
}
public static void main(String[] args) {
FieldCalculations calcFields = new FieldCalculations();
calcFields.search();
}
}