Java的Methods
本文参考这里
创建Method
modifier returnType nameOfMethod(Parameter List)
{
// method body
}
调用Method
略
传递参数 by-Value
略
方法重载(Method Overloading)
同名,不同参数(类型/数目)
使用命令行参数(Command-Line Arguments)
public class CmdlineTest
{
public static void main(String[] args)
{
for (String str : args)
{
System.out.println(str);
}
}
}
// 运行结果:
java CmdlineTest nice to meet you
nice
to
meet
you
构造函数(Constructors)
略
变参(Variable Arguments(var-args))
略
finalize()
方法
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
protected void finalize()
{
// finalization code here
}