我通常在Python中编写代码,并且我已经开始学习Java,但是我在调用带有参数的方法时感到困惑。事实上,在Python中,你可以调用一个函数像这样的说法:调用带参数的函数
my_function(argument)
在创建了像这样经过:
def my_function(argument):
#Here I can use my argument like this
print(argument) #if argument is a string
但我还没有找到如何做同样的事情在Java中。其实我特别想做到这一点:
return new webPage() //this call my file named "webPage"
//But when I'm calling, I want to send the url of the
//web page and recover it in the other file
http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html – exception1
你想在'return new webPage()'中放置'new'来实现什么? –
当您创建一个新对象时,您正在调用该类的构造函数,因此您需要创建一个接受参数的构造函数。 – Martin