为什么两个public就无法运行了!
public class Element{
// names of the chemical elements in alphabetical order
public static final String[] names = {
"Actinium", "Aluminium", "Americium", "Antimony", "Argon",
"Arsenic", "Astatine", "Barium", "Berkelium", "Beryllium",
"Bismuth", "Bohrium", "Boron", "Bromine", "Cadmium", "Caesium",
"Calcium", "Californium", "Carbon", "Cerium", "Chlorine",
"Chromium", "Cobalt", "Copper", "Curium", "Darmstadtium",
"Dubnium", "Dysprosium", "Einsteinium", "Erbium", "Europium",
"Fermium", "Fluorine", "Francium", "Gadolinium", "Gallium",
"Germanium", "Gold", "Hafnium", "Hassium", "Helium", "Holmium",
"Hydrogen", "Indium", "Iodine", "Iridium", "Iron", "Krypton",
"Lanthanum", "Lawrencium", "Lead", "Lithium", "Lutetium",
"Magnesium", "Manganese", "Meitnerium", "Mendelevium", "Mercury",
"Molybdenum", "Neodymium", "Neon", "Neptunium", "Nickel",
"Niobium", "Nitrogen", "Nobelium", "Osmium", "Oxygen",
"Palladium", "Phosphorus", "Platinum", "Plutonium", "Polonium",
"Potassium", "Praseodymium", "Promethium", "Protactinium",
"Radium", "Radon", "Rhenium", "Rhodium", "Roentgenium",
"Rubidium", "Ruthenium", "Rutherfordium", "Samarium", "Scandium",
"Seaborgium", "Selenium", "Silicon", "Silver", "Sodium",
"Strontium", "Sulphur", "Tantalum", "Technetium", "Tellurium",
"Terbium", "Thallium", "Thorium", "Thulium", "Tin", "Titanium",
"Tungsten", "Ununbium", "Ununhexium", "Ununoctium", "Ununpentium",
"Ununquadium", "Ununtrium", "Uranium", "Vanadium", "Xenon",
"Ytterbium", "Yttrium", "Zinc", "Zirconium"};
// approximate year of discovery for each element above
public static final int[] years = {
1899, 1825, 1944, 1540, 1894,
1250, 1940, 1808, 1949, 1798,
1753, 1975, 1808, 1826, 1817, 1860,
1808, 1950, 1, 1803, 1774,
1797, 1735, 1, 1944, 1994,
1967, 1886, 1952, 1842, 1890,
1952, 1866, 1939, 1880, 1875,
1886, 1, 1923, 1984, 1868, 1878,
1766, 1863, 1811, 1803, 1, 1898,
1839, 1961, 1, 1817, 1907,
1775, 1774, 1982, 1955, 1,
1778, 1885, 1898, 1940, 1751,
1801, 1772, 1958, 1803, 1774,
1803, 1669, 1735, 1940, 1898,
1807, 1885, 1945, 1913,
1898, 1900, 1925, 1804, 1994,
1861, 1844, 1964, 1879, 1878,
1974, 1817, 1824, 1, 1807,
1808, 1, 1802, 1937, 1782,
1843, 1861, 1828, 1879, 1, 1791,
1783, 1996, 2002, 2002, 2004,
1998, 2004, 1841, 1801, 1898,
1878, 1794, 1300, 1789};
}
public class ElementTest
{
public static void main(String[] args)
{
System.out.println("The first element in the list is " + Element.names[0] + ".");
System.out.println("It was discovered in " + Element.years[0] + ".");
System.out.println("It has " + Element.names[0].length() + " letters.");
System.out.println();
int arrayLength = Element.names.length;
System.out.println("The last element in the list is " + Element.names[arrayLength-1] + ".");
System.out.println("It was discovered in " + Element.years[arrayLength-1] + ".");
System.out.println();
System.out.println("There are " + arrayLength + " elements in the list.");
System.out.println("Hope his helps...");
System.out.println(); System.out.println();
}
}