public static void testAppend() { StringBuffer sb = new StringBuffer("This is a StringBuffer!"); sb.append(1.23f); System.out.println(sb.toString()); } 输出的是This is a StringBuffer!1.23f 关于StringBuffer对象的append方法介绍,在Ivor Horton所著的<Java 2 入门经典(J
一.String类的常用方法 1.获取: 1)获取字符串str长度 int i = str.length(); 2)根据位置(index)获取字符 char c = str.charAt(index); 3)获取字符在字符串中的位置 int i =str.indexOf(char ch); //获取的是第一次出现的位置 int i =str.indexOf(char ch ,int index); //从位置index后获取ch出现的第一次的位置 int i =str.indexOf(str1)
在MongoDB的官网已经很详细的介绍了各种客户端的使用,其中也包括java的,在此,仅对几个比较疑惑的地方做个标注: (1).如何向db中添加collection? 如果在api文档中找不到答案,那就去看源代码吧.可以看到com.mongodb.DB类中是如何定义getCollection方法的.其中DB类是抽象类,且doGetCollection(name)方法也是抽象的. /** * <strong>Gets a collection with a given name.</str
解决关于jquery中$.get()方法总是报“HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy”错的方法 今天在看<jquery基础教程(第三版)>第十章的时候,运行随书下载的源码时总是不成功.起初以为书中自带的JS文件有错呢,但是测来测去也没发现哪里有问题.现在把源码附下: 1.这是书中带的HTML文件,其余的忽略不计,关键的就是下面这个a. <a id=&qu
StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id from " + databaseprefix + "channel"); strSql.Append(" where name=@name "); StringBuilder的Append()方法会比+=效率高,StringBuilder比StringBuffer效率略高 +=,占资源的空间和时间