- Introduction
- Installation
- Junit
- Arrays
- Classes
- Data Types
- Expressions
- Interfaces
- JDBC
- Loops
- OOPS
- Serializable
- Strings
- Constructors
- Package
- Java Servlets
- Deployment
- Logging
- JSP
- ANT
- Web Services and Sockets
- Struts
- JPA
- Object Injection
- Annotations
- Reflection API
- Static Blocks
- Java Native Interface (JNI)
- Multithreading
- Tomcat Server
- Java Web Toolkit(JWT)
- Archive Files
- EJB(Enterprise Java Beans)
- JConsole
- Memory Profiling
- Hashing
- Exceptions
- Java Map Interface
- Java 8
- Garbage Collection
- Java 11
- Collections
- Java 17
Showing posts with label Flat. Show all posts
Showing posts with label Flat. Show all posts
Sunday, July 14, 2024
Streams
What is the flat map? how it is different from map?
- Map is used for data transformation whereas flat map is used for data transformation and flattering, the data.
- Map takes stream as input and output as another stream.
- It’s mapper function produces single value for each input value. Hence it is called as one to one mapping.
- It processes, a stream of values.
- It does Only mapping.
- Its mapper function produces a single value for each input value.
- It is a one-to-one mapping
- Data transformation from stream to stream.
- Use this method when the function is producing a single value for each input value.
- Flatmap is when map is added with flattening.
- It produces stream of values
- It performs mapping as well as flattening.
- Its map a function produces multiple values for each input value.
- It is one too many mapping.
- Data is transferred from one stream of stream to single stream.
- Use this method when the mapper function is producing multiple values for each input value.
- Flat map also takes a stream of input value and gives an output stream.
- Its map function produces multiple value for each input value. Hence it is called as one to many mapping.
- It is used to convert us stream of stream data to single stream, for example, a list of list of strings to a single list of strings.
Subscribe to:
Posts (Atom)
-
What are the different types of design patterns? Creational design patterns Structural design patterns Behavioural design patterns. List som...
-
What is the way to import only static members of a class? We can import using “import static packagename.classname.*” We can import using “i...
-
What is Second Level Caching in JPA? Shares entries across transactions. Second level cache is available between multiple sessions. It is av...