family.java
来自「Java 程序设计教程(第五版)EXAMPLESchap07源码」· Java 代码 · 共 33 行
JAVA
33 行
//********************************************************************
// Family.java Author: Lewis/Loftus
//
// Demonstrates the use of variable length parameter lists.
//********************************************************************
public class Family
{
private String[] members;
//-----------------------------------------------------------------
// Constructor: Sets up this family by storing the (possibly
// multiple) names that are passed in as parameters.
//-----------------------------------------------------------------
public Family (String ... names)
{
members = names;
}
//-----------------------------------------------------------------
// Returns a string representation of this family.
//-----------------------------------------------------------------
public String toString()
{
String result = "";
for (String name : members)
result += name + "\n";
return result;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?