Somith Patel wrote:Please help me to understand the how can i build the payload to get HouseType in List.
There are a number of ways to do this, and there's not really a single standard way that everyone has settled on.
The List interface has some static methods that can help you - look at the List.of() methods. You can use these to write something like this:
Note that I've renamed abc() to abcs(), because I like using a plural form for lists and arrays.
Here your abcs() method accepts a List<ABC>, and you use List.of() to make the List of ABC objects.
If you've learned about varargs, you can also use that to write an abc() method that accepts a comma-separated list (not List) of ABC objects:
code]Example ex = Example.builder()
It's a small difference, but a little easier to use, and more readable.
Personally, for Lists and other collections, I often find it helpful to also have an add() method that lets you add an individual element, like this:
Note that this may not work well with the first approach - a List.of() method creates an unmodifiable list, so if you then do a list.add(), it won't work. So you may need to do additional work to copy the original List to a separate ArrayList, created by you in the builder class, that you know is mutable.
If those options are too confusing at beginner level, don't worry - just focus on the first one; that's simplest to understand. The others can be considered later.