`
文章列表

一个新起点

    博客分类:
  • blog
 
http://cho.icxo.com/htmlnews/2006/09/06/927462.htm 是金子在哪都会闪光。踏踏实实学习,不断进步。
求全排列一共有四种方法,字典序法,递增进位制数法,递减进位制数法,邻位对换法.我在这里讲最简单的字典序法. 这个生成法要求传进来的序列必须已经按从小到大人规律排过序.否则它不能生成正确的全排列.至于为什么用这个方法就可以生成全排列,我的知识有限,证明不了,只有拿来用了再说. 假定序列为a1,a2.... an (n > 0) ,如123456789,它从123456789开始,一直到987654321结束,中间有n个值,寻找这n个值需要做n步下面的操作: 1.找出比右边数字小的第一个数 找到这个数后,把它的位置记下来.设这个位置为pos_left;如果找不到,就说明排列完成了. 2.从右 ...
求全排列一共有四种方法,字典序法,递增进位制数法,递减进位制数法,邻位对换法.我在这里讲最简单的字典序法. 这个生成法要求传进来的序列必须已经按从小到大人规律排过序.否则它不能生成正确的全排列.至于为什么用这个方法就可以生成全排列,我的知识有限,证明不了,只有拿来用了再说. 假定序列为a1,a2.... an (n > 0) ,如123456789,它从123456789开始,一直到987654321结束,中间有n个值,寻找这n个值需要做n步下面的操作: 1.找出比右边数字小的第一个数 找到这个数后,把它的位置记下来.设这个位置为pos_left;如果找不到,就说明排列完成了. 2.从右 ...
java 代码   private PersonAggregateData copyAggregate(PersonAggregateData original) throws EventsPersonManagementException {              ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();       ObjectOutputStream out = null;       ObjectInputStream in = null;   ...

外连接

如果要从boys, girls两张表中查住在同一个城市的男孩和女孩,要保留没有匹配的记录的信息,则需要用外连接。 sql 代码   select city, name from offices, salesreps   where office*=rep_office;   *侧的为需要保留的没有匹配的记录。另一侧补null   1.按正常方式使用匹配字段生成两个表的内连接。 2.对于第一个表中不被第二个表任意记录匹配的记录,使用第一个表中的值,添加一条记录到查询结果中,交假定第二个表中所有字段为null. 3.同2类似处理第二个表中不被第一个表中任意记录匹配的 ...
1.求一个整数序列的最长递增子序列。 2.编辑距离算法。即从一个字符串转换成另一个字符串的最少操作次数。允许添加,删除或是替换字母。 3.两个整数数组,从每个数组中有序取m个数,两两相乘后的和最大。求最大和。 4.求两个字符串的最长公共子串。 java 代码   2.编辑距离算法。即从一个字符串转换成另一个字符串的最少操作次数。允许添加,删除或是替换字母。 public int getDistance(String s1, String s2) {          int[][] array = new int[s1.length() + 1][s2.length() +  ...
java 代码      Class.forName("oracle.jdbc.driver.OracleDriver");        Connection   conn   =DriverManager.getConnection(strConnectionURL,strUserName,  strPassWord);        
Form-Letter Programming VS MessageFormat 今天阅读<<编程珠玑>>时发现讲到了Form-Letter Programming,其实这种思想在jdbc,hibernate等地方都有用到。即在字符串中给待替换的参数起个名字,之后将这个名字替换成相应的参数。 正好前几天在阅读代码时看到人家用MessageFormat。这个类完全是Form-Letter Programming的实现。现将这个类的用法给个示例: java 代码 int planet = 7;    String event = "a dist ...
    现在看了,知道了,太简单了,其实说白了,StringBuffer 和 StringBuilder 的区别就如同 HashTable 和 HashMap 的区别;就如同 ArrayList 和 Vector 的区别。是的,只是区别在同步与非同步上、线程安全与不安全,同时由此影响的单线程环境时的性能上。     StringBuffer 和 StringBuilder 在提供给外部方法是一样的,只是 StringBuffer 的方法前都加有 synchronized 关键字,而 StringBuilder的方法前没有 synchronized 。因此 StringBuilder 比 Str ...
Levenshtein Distance Algorithm: Oracle PL/SQL Implementation by Barbara Boehmer (baboehme@hotmail.com) sql 代码   CREATE OR REPLACE FUNCTION ld -- Levenshtein distance     (p_source_string   IN VARCHAR2,      p_target_string   IN VARCHAR2)     RETURN                NUMBER     DETE ...
java 代码   **   * Calculates the number of days between two calendar days in a manner   * which is independent of the Calendar type used.   *   * @param d1    The first date.   * @param d2    The second date.   *   * @return      The number of days between the two dat ...
xml 到Documetn java 代码   public XmlFileConfigurationStrategy(File xmlSource//TODO validate should be used       throws ConfigurationException {       Helper.checkObject(xmlSource, "xmlSource");          try {           xmlDocument = createDocumentBuilder().parse(xml ...

The JNDI Tutorial

    博客分类:
  • J2EE
http://java.sun.com/products/jndi/tutorial/
java 代码   // reads the properties from the property file          Properties props = new Properties();          try {              props.load(new FileInputStream(PROPERTIES_FILE));          } catch (IOException ex) {              System.out.println("error configuring un ...
java 代码   /**   * Reads a text file to a String. The result String includes a '\n' after   * each line in the file.   *    * @param fileName the name of the file to read   * @return the content of the file in String format. The return String   *         includes a '\n' a ...
Global site tag (gtag.js) - Google Analytics