[蟲?] cannot find symbol

看板java作者 (Love Moives)時間10年前 (2014/12/08 21:22), 編輯推噓0(009)
留言9則, 5人參與, 最新討論串1/1
抱歉本人不會JAVA 發現只要是像在^^^標註中的寫法,就會有cannot find symbol的問題 JavaRDD<Integer> lineLengths = lines.map(new Function<String, Integer>() { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ public Integer call(String s) { return s.length(); } }); int totalLength = lineLengths.reduce(new Function2<Integer, Integer, Integer>() { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ public Integer call(Integer a, Integer b) { return a + b; } }); javac -version javac 1.7.0_72 在mvn的pom.xml檔中設定 ,也是一樣 <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> 困了幾天了,還是交給專業的來好了 感謝 -- -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.110.107.24 ※ 文章網址: http://www.ptt.cc/bbs/java/M.1418044969.A.E0E.html

12/08 22:18, , 1F
new後面是class名,你有定義叫做Function的class嗎?
12/08 22:18, 1F

12/08 22:32, , 2F
請問一下 anonymous class是JAVA7支援還是JAVA8
12/08 22:32, 2F

12/08 22:54, , 3F
感謝 樓上提示,解決了,java8才有支援,所以我多引用東西
12/08 22:54, 3F

12/09 04:33, , 4F
anonymous class是Java 5還是6支援的....
12/09 04:33, 4F

12/09 04:35, , 5F
Lambda才是Java8 不過你這個看起來是Anonymous Class
12/09 04:35, 5F

12/10 18:36, , 6F
map/reduce是哪來的,Function是哪來的
12/10 18:36, 6F

12/10 18:37, , 7F
找不到不就是沒import? 又沒寫出你的import...
12/10 18:37, 7F

12/10 18:38, , 8F
不支援的語法錯誤訊息不會是cannot find symbol
12/10 18:38, 8F

12/13 20:12, , 9F
import org.apache.spark.api.java.function.*;
12/13 20:12, 9F
文章代碼(AID): #1KXQOfuE (java)
文章代碼(AID): #1KXQOfuE (java)