格式化代码
This commit is contained in:
@@ -2,21 +2,24 @@
|
||||
// {Requires: nu.xom.Node; You must install
|
||||
// the XOM library from http://www.xom.nu }
|
||||
// {RunFirst: Person}
|
||||
|
||||
import nu.xom.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class People extends ArrayList<Person> {
|
||||
public People(String fileName) throws Exception {
|
||||
Document doc = new Builder().build(fileName);
|
||||
Elements elements =
|
||||
doc.getRootElement().getChildElements();
|
||||
for(int i = 0; i < elements.size(); i++)
|
||||
add(new Person(elements.get(i)));
|
||||
}
|
||||
public static void main(String[] args) throws Exception {
|
||||
People p = new People("People.xml");
|
||||
System.out.println(p);
|
||||
}
|
||||
public People(String fileName) throws Exception {
|
||||
Document doc = new Builder().build(fileName);
|
||||
Elements elements =
|
||||
doc.getRootElement().getChildElements();
|
||||
for (int i = 0; i < elements.size(); i++)
|
||||
add(new Person(elements.get(i)));
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
People p = new People("People.xml");
|
||||
System.out.println(p);
|
||||
}
|
||||
} /* Output:
|
||||
[Dr. Bunsen Honeydew, Gonzo The Great, Phillip J. Fry]
|
||||
*///:~
|
||||
|
||||
Reference in New Issue
Block a user