toyexample.java
来自「java编程代码」· Java 代码 · 共 39 行
JAVA
39 行
/**
Demonstrates the correct way to define an accessor
method to a private array of class objects.
*/
public class ToyExample
{
private Date[] a;
public ToyExample(int arraySize)
{
a = new Date[arraySize];
for (int i = 0; i < arraySize; i++)
a[i] = new Date( );
}
public ToyExample(ToyExample object)
{
int lengthOfArrays = object.a.length;
this.a = new Date[lengthOfArrays];
for (int i = 0; i < lengthOfArrays; i++)
this.a[i] = new Date(object.a[i]);
}
public Date[] getDateArray( )
{
Date[] temp = new Date[a.length];
for (int i = 0; i < a.length; i++)
temp[i] = new Date(a[i]);
return temp;
}
// <There presumably are other methods that are not shown,
//but they are irrelevant to the point at hand.>
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?