Title: Java class convention dealing with arraylist
Tags: java;convention
Question: My question is in regards to better convention for class design. I am currently working on a project for school where I am to use a class to create an object for a unit conversion calculator. I want to store these objects into an arraylist.
My question is, does it matter if I create and .add to the arraylist from the main method, or is it better to think about using the conversion class to deal with the array?
Comment: Depends on your future changes. just for a single method creating a new class is pretty heavy. But when you consider SOLID principles and future maintainability its a good practice.

Comment: It is not really clear what your question is. What do you mean by a "conversion class"? Please add some code showing the two alternatives you are considering.  Writing the code will help us understand the question, and help you in formulating it.


Here is another answer: The main method is a starting point for execution. That's a place only for processing application arguments (args) and creating an instance that represents the whole application*. Normally, the class that contains main should be stateless.
A good example - a Spring Boot initialiser:
public class Runner {
public static void main(String... args) {
SpringApplication.run(Runner.class, args); // all the magic is in there
Sometimes, to adhere to the single responsibility principle, we direct args handling and initialization of the principal object to different classes.

Here is another answer: It is better to create a separate class. It is very good practice and help you a lot to maintain when your project will grow in future.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:10/30/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<java><convention>', 'Title': 'Java class convention dealing with arraylist', 'ViewCount': 108, 'id': 47016290, 'user_AboutMe': None, 'user_AccountId': 10841995.0, 'user_DisplayName': 'D. Guitner', 'user_Reputation': 17.0, 'user_Views': 2.0, 'user_id': 7972917.0}}