📄 pair.java
字号:
/** This class represents a pair of objects. */
public class Pair
{
/** The first item of the pair. */
public Object firstItem;
/** The second item of the pair. */
public Object secondItem;
/** Create a pair with initial values v1 and v2.
Analysis: Time = O(1) */
public Pair(Object v1, Object v2)
{
firstItem = v1;
secondItem = v2;
}
/** String representation of the pair.
Analysis: Time = O(1) */
public String toString()
{
return ( "(" + firstItem + "," + secondItem + ")" );
}
/** Does this pair have equal variable values as the pair referenced by other?
Analysis: Time = O(1) */
public boolean equals(Object other)
{
Pair otherPair = (Pair) other;
return firstItem == otherPair.firstItem && secondItem == otherPair.secondItem;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -