如何有效地使用main方法? [英] How to use main method efficiently?

查看:90
本文介绍了如何有效地使用main方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在main方法中从控制台或文件中获取输入,然后使用getter方法将该数据传递到另一个类并在该类中使用该数据,是否会导致数据重复?这样做是一个很好的编程习惯吗?如果没有,你会建议做什么?



我尝试过:



我想知道这是不是一个很好的做事方式,如果是我会试一试。

If I take input from console or file in my main method and then using getter methods pass that data into another class and use that data in that class, would this cause duplication of data? Is it a good programming habit to do that? If not, what would you suggest to do?

What I have tried:

I was wondering if this is a good way to do stuff, if it is than I will give it a try.

推荐答案

是的,它是处理属于类对象的数据的正确方法。请参阅课程:类和对象(Java教程) [ ^ ]了解更多信息。
Yes, it is the right way to handle data that belongs to a class object. See Lesson: Classes and Objects (The Java Tutorials)[^] for more information.


这篇关于如何有效地使用main方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆