I'm trying to create & populate Shapefile in Java using GeoTools.
Basically following this link (quite similar to the official documentation & other tutorials specifically for the point I'm asking below).
For below code I'm getting first warning that
FeatureCollections is deprecated and error that
add() cannot be resolved.
FeatureCollection<SimpleFeatureType, SimpleFeature> collection = FeatureCollections.newCollection(); ... collection.add(feature);
How can I fix that or any other way to create Shapefile using Java?