I am new to Java and started working with a startup as an intern. I am stuck in a situation where I want to use the same names for two different Java fields with different types.
For example:
I had an API contract wherein a field called private String privateNews.
Also, I have already stored some of the data with the above contract in the database.
Now I want to change it to a private List<String> privateNews with keeping name same.
Replacing the current field is causing a serialization issue while fetching entries from the database (MongoDB).
I am thinking to keep both fields for some time and do the migration.
Is there a way I can use the same name with different types of fields in Java? or any other solution to deal with such problems?