I recently made it through to the final round of interview.
At one point in the interview, they asked me to demonstrate my Java 8 knowledge on the following piece of code. They asked me to reduce the following code using either Optional.of() or Stream.of(). And I was completely frozen, I only ever used streams on lists and didn't know how to use the optional approach. I didn't get the job specifically for this reason, as they said my understanding of java8 wasn't good enough. Can someone please tell me what they were looking for?
Summary
I've been specifically asked to reduce these 2 lines with Optional.of() or Stream.of():
gameDto = gameplay.playRandomGame(gameDto);
repo.updateTotals(gameDto.getResult());
Overall snippet for a bit of context:
@Service("gameService")
public class GameServiceImpl implements GameService{
    
    @Autowired
    private SessionInMemoryRegistry sessionRegistry;
    
    @Autowired
    private GameInMemoryRepo repo;
    
    @Autowired
    private GamePlay gameplay;
    @Override
    public ResponseDto addGameToSession(GameDto gameDto) {
        gameDto = gameplay.playRandomGame(gameDto);
        repo.updateTotals(gameDto.getResult());
        return sessionRegistry.addGameSession(gameDto.getSessionId(), gameDto.getPlayer1Choice(), gameDto.getPlayer2Choice(), gameDto.getResult());
    }
}
 
     
    