Blog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2025 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Kotlin
Kotlinhard

Flow vs Sequence — what’s the key difference?

Tags
#flow#sequence#streams
Back to categoryPractice quiz

Answer

`Sequence` is synchronous and lazy on the current thread. `Flow` is a cold asynchronous stream that can suspend, is cancellable, and is collected with coroutines (`collect`), which makes it good for async data streams.

flow {
  emit(1)
  emit(2)
}.collect { value ->
  println(value)
}

Related questions

Kotlin
Channel vs Flow - how are they different in coroutines?
#kotlin#coroutines#flow
Kotlin
StateFlow vs SharedFlow — what’s the practical difference?
#stateflow#sharedflow#flow
Java
Parallel streams: when can they help and what are common pitfalls?
#java#streams#parallel
Java
Streams vs collections: what is the difference and a common pitfall?
#streams#collections#side-effects
PostgreSQL
Sequences/IDENTITY: why can generated IDs have gaps?
#sequence#identity#transactions