Trying to run the below code in Scala. It returns a "missing parameter type" error.
def printTree(e: Element, depth: Int){
System.out.println("Number of children in element : ",e.getChildren().getClass());
System.out.println(StringUtils.repeat("\t", depth) + e.getText());
e.getChildren().stream().filter(c=>c instanceOf Element).foreach(c=>printTree((Element)c, depth+1));
}
In Scala you don't need to explicitly work with Java streams. If e.getCgildren()
return an Array
, you can omit .stream()
and the rest will compile.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.