1)select Fclass, max(Fscore) from table group by Fclass, Fid;
2)单例模式
1 public class Singleton{ 2 /* 懒汉式 */ 3 private static Singleton instance = new Singleton(); 4 5 private Singleton(){} 6 7 public static Singleton getInstance(){ 8 return instance; 9 } 10 } 11 12 public class Singleton{ 13 /* 饿汉式 */ 14 private static Singleton instance = null; 15 16 private Singleton(){} 17 18 public static Singleton getInstance(){ 19 if(instance == null) 20 instance = new Singleton(); 21 return instance; 22 } 23 }
3)冒泡排序
1 public void BubbleSort(int[] a, int n){ 2 boolean change = true; 3 for(int i = 1; i < n && change; i++){ 4 change = false; 5 for(int j = 0; j < n - i; j++){ 6 if(a[j] > a[j + 1]){ 7 int t = a[j]; 8 a[j] = a[j + 1]; 9 a[j + 1] = t; 10 change = true; 11 } 12 } 13 } 14 }
4)DOM、SAX、JDOM、DOM4J
1 public class HrReader { 2 public void readXml() { 3 String inputXml = "E:/hr.xml"; 4 SAXReader saxReader = new SAXReader(); 5 try { 6 Document document = saxReader.read(inputXml); 7 Element root = document.getRootElement(); 8 List<Element> employees = root.elements("employee"); 9 for (Element employee : employees) { 10 Attribute att = employee.attribute("no"); 11 System.out.print(att.getText() + " "); 12 13 System.out.print(employee.elementText("name") + " "); 14 System.out.print(employee.elementText("age") + " "); 15 System.out.print(employee.elementText("salary") + " "); 16 17 Element department = employee.element("department"); 18 System.out.print(department.element("dname").getText() + " "); 19 System.out.println(department.element("address").getText()); 20 } 21 } catch (DocumentException e) { 22 e.printStackTrace(); 23 } 24 } 25 26 public static void main(String[] args) { 27 HrReader hrReader = new HrReader(); 28 hrReader.readXml(); 29 } 30 }