英文:
Java version of Python's def function
问题
虽然我最擅长Python,但最近我开始学习Java。我想知道在Java中是否有类似于Python的def
函数的功能。我正在寻找一种类似的东西,允许我编写一些代码并将其存储在可调用的函数内部。
英文:
While I am most fluent in Python, I've recently started learning Java. I was wondering if there is a similar function in Java to Python's def function. Something that allows me to write some code and store it within a callable function is what I am looking for.
答案1
得分: 1
不,Java没有用于声明函数的def关键字,而是在类内部声明方法,例如:
public static void myMethod(String[] args) {
英文:
No, java Dosen't have any def keyword for declaring functions, instead it has declaring methods inside classes like:
public static void myMethod(string[] args){
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论