如何操纵方法中的变量并将其发送回去
我已经看到了几个问题,但是我还没有找到答案。因此,我基本上一直在尝试将所有基于所有基于内部方法的东西都充满了对方法的通话,但是,我遇到了试图实际操纵数据,通过方法并将其保存到MAIM的问题。这不是我要编写的实际代码,但这几乎封装了我的问题。
I've seen a few questions about this but I haven't been able to find the answer yet. So I'm basically been trying to have everything based inside methods and only have the main full of calls to the methods but, I'm running into problems trying to actually manipulate data, pass them through the methods and save it into main. This isn't the actual code I'm trying to write but this pretty much encapsulates my problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
方法无法操作输入参数,您需要声明方法的返回值。像这样:
然后这样调用它:
这是非常基本的东西,你应该去阅读一些 Java 编程的介绍,例如 Oracle Java 教程。
Methods cannot manipulate input parameters, you will need to declare return values for your methods. Like this:
And then call it like this:
This is pretty basic stuff, you should go read some introduction to Java programing, such as the oracle java tutorial.