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.Array s;
import java.util.Colle ctions;
import java.util.Array List;
/**
* @author HP_Owner
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class FieldCalculatio ns {
private static final String colors[]={"red","green" ,"blue"};
private List < String > list; // *************** compiler generates error on
this line*********
public SearchTest()
{
list=new ArrayList<Strin g>(Arrays.asLis t(colors));
Collections.sor t(list);
}
private void search()
{
getIndex("green ");
}
private int getIndex(String key)
{
int result=0;
result=Collecti ons.binarySearc h(list,key);
if(result >=0)
return result;
else
System.out.prin tln("error not found "+ result);
}
public static void main(String[] args) {
FieldCalculatio ns calcFields = new FieldCalculatio ns();
calcFields.sear ch();
}
}
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.Array s;
import java.util.Colle ctions;
import java.util.Array List;
/**
* @author HP_Owner
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class FieldCalculatio ns {
private static final String colors[]={"red","green" ,"blue"};
private List < String > list; // *************** compiler generates error on
this line*********
public SearchTest()
{
list=new ArrayList<Strin g>(Arrays.asLis t(colors));
Collections.sor t(list);
}
private void search()
{
getIndex("green ");
}
private int getIndex(String key)
{
int result=0;
result=Collecti ons.binarySearc h(list,key);
if(result >=0)
return result;
else
System.out.prin tln("error not found "+ result);
}
public static void main(String[] args) {
FieldCalculatio ns calcFields = new FieldCalculatio ns();
calcFields.sear ch();
}
}
Comment