What if you're just testing or you want to dynamically create features using only Java code?
There is no need to load data from a file or other DataStore.
Here's a handy-dandy little example that creates a custom MapLayer with a FeatureCollection containing one feature, my house:
Labels