V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
8e47e42
V2EX  ›  问与答

Java stream 一个 ArrayList,在 ForEach 下如何获得前一个元素?

  •  
  •   8e47e42 · Apr 1, 2020 · 1581 views
    This topic created in 2217 days ago, the information mentioned may be changed or developed.
    如题问,for loop 能很容易的读到 i-1,但是 for each 下面怎么获得呢?
    3 replies    2020-04-01 13:57:27 +08:00
    lhx2008
        1
    lhx2008  
       Apr 1, 2020
    不要使用 forEach
    optional
        2
    optional  
       Apr 1, 2020
    迭代器是不能获取前一个的,除非你自己记下来
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5827 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 62ms · UTC 01:51 · PVG 09:51 · LAX 18:51 · JFK 21:51
    ♥ Do have faith in what you're doing.