以下是从Java中的Octet类实现Ennead类的示例-
示例import org.javatuples.Octet;
import org.javatuples.Ennead;
public class MyDemo {
public static void main(String[] args) {
Octet
octet = new Octet(
"Jack", "Tom", "Steve", "Tim", "Nathan", "Ryan", "Kevin", "Katie");
System.out.println("Octet elements = " + octet);
Enneadennead = octet.add("Scarlett");
System.out.println("Ennead (implemented from Octet): " + ennead);
}
}
输出结果Octet elements = [Jack, Tom, Steve, Tim, Nathan, Ryan, Kevin, Katie]
Ennead (implemented from Octet): [Jack, Tom, Steve, Tim, Nathan, Ryan, Kevin, Katie, Scarlett]
现在让我们看到另一个示例,其中将使用addAt2()。该方法在位置3rd处插入。这也实现了Octet类的Ennead类-
示例import org.javatuples.Octet;
import org.javatuples.Ennead;
public class MyDemo {
public static void main(String[] args) {
Octet
octet = new Octet(
"Jack", "Tom", "Steve", "Tim", "Nathan", "Ryan", "Kevin", "Katie");
System.out.println("Octet elements = " + octet);
Enneadennead = octet.addAt2("Jacob");
System.out.println("Ennead (implemented from Octet): " + ennead);
}
}
输出结果Octet elements = [Jack, Tom, Steve, Tim, Nathan, Ryan, Kevin, Katie]
Ennead (implemented from Octet): [Jack, Tom, Jacob, Steve, Tim, Nathan, Ryan, Kevin, Katie]