Array 的操作方法和 String 的操作方法老是弄混>_<,下面就对于这两个对象的常用操作方法进行比较~~

Array

☞ 操作方法
  1. concat():returns a new array comprised of the array on which it is called joined with the array(s) and/or value(s) provided as arguments.

     var new_array = old_array.concat(value1[, value2[, ...[, valueN]]])
  2. slice():returns a shallow copy of a portion of an array into a new array object.→ 切片

     arr.slice([begin[, end]])
  3. splice():changes the content of an array by removing existing elements and/or adding new elements.→ 拼接

     array.splice(start, deleteCount[, item1[, item2[, ...]]])

String

☞ 操作方法
  1. concat():将一个或多个字符串与原字符串连接合并,形成一个新的字符串并返回。

     str.concat(string2, string3[, ..., stringN])
  2. slice():extracts a section of a string and returns a new string.→ 切片

     str.slice(beginSlice[, endSlice])
  3. substr():returns the characters in a string beginning at the specified location through the specified number of characters.(返回一个从指定位置开始的指定长度的子字符串。)

     str.substr(start[, length])
  4. substring():returns a subset of a string between one index and another, or through the end of the string.(返回位于 String 对象中指定位置的子字符串。)

     str.substring(indexStart[, indexEnd])
☞ 模式匹配方法
  1. match()

  2. search()

  3. replace()

  4. split():通过把字符串分割成子字符串来把一个 String。 对象分割成一个字符串数组。→ 拆分

     str.split([separator][, limit])

Array操作方法和String操作方法比较的更多相关文章

  1. java中setDate(Date date)方法和String与Date之间的转换

    经常在开发的过程中遇到这样的问题,从数据库中读出来的数据需要转换为对像或者java bean,此时经常使用到setDate(Date date);这样的方法.感觉这是个很简单而又难受的事情,在这里浪费 ...

  2. 详解Integer.toString(int i)方法和String.valueOf(int i)方法

    通过查看String类的源码: public static String valueOf(int i) { return Integer.toString(i); } 我们可以看到,String.va ...

  3. java数组、java.lang.String、java.util.Arrays、java.lang.Object的toString()方法和equals()方法详解

    public class Test { public static void main(String[] args) { int[] a = {1, 2, 4, 6}; int[] b = a; in ...

  4. Junit 注解 类加载器 .动态代理 jdbc 连接池 DButils 事务 Arraylist Linklist hashset 异常 哈希表的数据结构,存储过程 Map Object String Stringbufere File类 文件过滤器_原理分析 flush方法和close方法 序列号冲突问题

    Junit 注解 3).其它注意事项: 1).@Test运行的方法,不能有形参: 2).@Test运行的方法,不能有返回值: 3).@Test运行的方法,不能是静态方法: 4).在一个类中,可以同时定 ...

  5. Object、String、数组的 toString() 方法和 equals() 方法及java.util.Arrays

    public class Test { public static void main(String[] args) { int[] a = {1, 2, 4, 6}; int[] b = a; in ...

  6. TP框架中的A方法和R方法

    ThinkPHP 跨模块调用操作方法(A方法与R方法) 跨模块调用操作方法 前面说了可以使用 $this 来调用当前模块内的方法,但实际情况中还经常会在当前模块调用其他模块的方法.ThinkPHP 内 ...

  7. toString方法和valueof()方法的区别

    JavaScript引用类型之Array数组的toString()和valueof()方法的区别   一.转换方法 1.在JavaScript中几乎所有对象都具有toLocaleString().to ...

  8. Android HTTP实例 使用GET方法和POST方法发送请求

    Android HTTP实例 使用GET方法和POST方法发送请求 Web程序:使用GET和POST方法发送请求 首先利用MyEclispe+Tomcat写好一个Web程序,实现的功能就是提交用户信息 ...

  9. wait方法和sleep方法的区别

    一.概念.原理.区别 Java中的多线程是一种抢占式的机制而不是分时机制.线程主要有以下几种状态:可运行,运行,阻塞,死亡.抢占式机制指的是有多个线程处于可运行状态,但是只有一个线程在运行.      ...

随机推荐

  1. return false取消手机移动端的默认设置

    想做一个语音界面,当长按语音按钮的时候,总会出现移动端什么复制粘贴菜单.然后在JS中加入return false后就消失了,感觉好神奇哦~

  2. 8种NOsql

    虽然SQL数据库是非常有用的工具,但经历了15年的一支独秀之后垄断即将被打破.这只是时间问题:被迫使用关系数据库,但最终发现不能适应需求的情况不胜枚举. 但是NoSQL数据库之间的不同,远超过两 SQ ...

  3. 你所知道的Java单例模式并不是单例模式

    当我们搜索单例模式的时候,能看到很多例子,什么懒汉式.饿汉式,大概如下: public class Singleton { private static Singleton instance=null ...

  4. J2EE开发实战基础系列一 HelloWorld【转】

      开始咱们的第一个程序,首先是配置环境,按照上一章所描述的方式下载开发工具,然后配置Java环境变量,给大家看下具体的结构: 环境变量配置OK的提示,如上图. Eclipse和Tomcat的文件目录 ...

  5. VS2010 winform程序发布步骤

    1.右键单击解决方案,点击“添加”---“新建项目”,如下图: 2.选择“其他项目类型”--“安装和部署”--“Visual Studio Installer”---"安装项目", ...

  6. 【工具推荐】ELMAH——可插拔错误日志工具

    今天看到一篇文章(构建ASP.NET网站十大必备工具(2)),里面介绍了一个ELMAH的错误日志工具,于是研究了一下. ELMAH 是 Error Logging Modules and Handle ...

  7. LTP学习

    下载LTP源码和模型文件: https://github.com/linux-test-project/ltp 官方说明文档 http://ltp.readthedocs.org/zh_CN/late ...

  8. mysql一次添加多条记录

    inisert into tabale (name,pwd) values ("jom","123"),("tom","123&q ...

  9. tableview 刷新 @property属性的用法

    1.tableView的刷新1> 数据刷新的总体步骤* 修改模型数据* 刷新表格(刷新界面) 2> 刷新表格(刷新界面)的方法* 全局刷新(每一行都会重新刷新)- (void)reload ...

  10. [流媒体]live555简介(转)

    live555简介 Live555 是一个为流媒体提供解决方案的跨平台的C++开源项目,它实现了对标准流媒体传输协议如RTP/RTCP.RTSP.SIP等的支持.Live555实现 了对多种音视频编码 ...