Java版本的Python的def函数

huangapple go评论73阅读模式
英文:

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>



huangapple
  • 本文由 发表于 2020年10月4日 10:36:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/64190684.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定