I have problem importing java.util.stream.*;
Compiling my code gives me a stream()
"cannot find symbol error".
This is my import list
import java.util.stream.*;
import java.util.*;
import java.lang.String;
import java.util.Arrays;
import java.nio.file.*;
import java.io.IOException;
and this is the code i'm compiling
List<Beverage> l = cantine.stream()
.filter(p -> p.name.equals(nam))
.collect(Collectors.toList());
IMPORTANT: I do know what a "cannot find symbol error" is, so please do not blindly close this question.
full code for reference
import java.util.stream.*;
import java.util.*;
import java.lang.String;
import java.util.Arrays;
import java.nio.file.*;
import java.io.IOException;
public class Enoteca{
Map<String,Beverage> cantine;
public Enoteca(){
this.cantine = new HashMap<String,Beverage>();
}
public List<Beverage> byName(String nam){
List<Beverage> l = cantine.stream()
.filter(p -> p.name.equals(nam))
.collect(Collectors.toList());
}
public static void main(String[] args){
Enoteca e = new Enoteca();
for(String s: args){
Beverage b = new Beverage(s,"1987");
e.cantine.put(s,b);
}
System.out.println(e.cantine);
}
}
class Beverage{
String name;
String year;
public Beverage(String name,String year){
this.name = name;
this.year = year;
}
public String getName(){
return name;
}
@Override
public String toString(){
return name + " " +year;
}
}