易截截图软件、单文件、免安装、纯绿色、仅160KB

java字符串处理

 1、length() 字符串的长度
  例:char chars[]={'a','b'.'c'};
    String s=new String(chars);
    int len=s.length();
2、charAt() 截取一个字符
  例:char ch;
    ch="abc".charAt(1); 返回'b'
3、getChars() 截取多个字符
  void getChars(int sourceStart,int sourceEnd,char target[],int targetStart)
   sourceStart指定了子串开始字符的下标,sourceEnd指定了子串结束后的下一个字符的下标。因此,子串包含从sourceStart到 sourceEnd-1的字符。接收字符的数组由target指定,target中开始复制子串的下标值是targetStart。
  例:String s="this is a demo of the getChars method.";
    char buf[]=new char[20];
    s.getChars(10,14,buf,0);
4、getBytes()
  替代getChars()的一种方法是将字符存储在字节数组中,该方法即getBytes()。
5、toCharArray()
6、equals()和equalsIgnoreCase() 比较两个字符串
7、regionMatches() 用于比较一个字符串中特定区域与另一特定区域,它有一个重载的形式允许在比较中忽略大小写。
  boolean regionMatches(int startIndex,String str2,int str2StartIndex,int numChars)
  boolean regionMatches(boolean ignoreCase,int startIndex,String str2,int str2StartIndex,int numChars)
8、startsWith()和endsWith()
  startsWith()方法决定是否以特定字符串开始,endWith()方法决定是否以特定字符串结束
9、equals()和==
  equals()方法比较字符串对象中的字符,==运算符比较两个对象是否引用同一实例。
  例:String s1="Hello";
    String s2=new String(s1);
    s1.eauals(s2); //true
    s1==s2;//false
10、compareTo()和compareToIgnoreCase() 比较字符串
11、indexOf()和lastIndexOf()
  indexOf() 查找字符或者子串第一次出现的地方。
  lastIndexOf() 查找字符或者子串是后一次出现的地方。
12、substring()
  它有两种形式,第一种是:String substring(int startIndex)
         第二种是:String substring(int startIndex,int endIndex)
13、concat() 连接两个字符串
14 、replace() 替换
  它有两种形式,第一种形式用一个字符在调用字符串中所有出现某个字符的地方进行替换,形式如下:
  String replace(char original,char replacement)
  例如:Strin


相关文档:

sql 2005 存储过程分页 java 代码

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列 ......

java exception java异常汇总2009

java exception 解决方案 - 我的异常网|异常|exception|myexception 831 - ActionMessages 832 - could not instantiate id generator 833 - javax.servlet.jsp.JspException 834 - javax.naming.NoInitialContextException 835 - net.sf.hibernate.HibernateException 836 - org.hibernate.exception.GenericJDBCExceptio ......

浅谈Java泛型编程

 
浅谈Java泛型编程
1 引言在JDK 1.5中,几个新的特征被引入Java语言。其中之一就是泛型(generics)。泛型(generics,genericity)又称为“参数类型化(parameterized type)”或“模板(templates)”,是和继承(inheritance)不同而互补的一种组件复用机制。继承和泛型的不同之处在于&mda ......

java,php,mysql时间处理

java中时间戳和时间字符串之间的转换
获取当前的unix时间戳
new Date().getTime()
System.currentTimeMillis()
返回的是毫秒数,要转换long t = System.currentTimeMillis()/1000;
获取当前年月日以及时分秒
Calendar c = Calendar.getInstance();
c.get(Calendar.YEAR))  c.get(Calendar.YEAR))  c.get(C ......

JAVA里的PING和TELNET

JAVA里的PING是在JDK 1.5后用了新的函数isreachable去实现,具体介绍如下:
InetAddress对象的常用方法

InetAddress类有很多
get
方法,用来获取主机名,主机地址等信息。主要有:
byte[] getAddress() 返回次
InetAddress
对象的原始
IP
地址,保存为一个
byte
数组
String getCanonicalHostName() 获取此
I ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号