1 CharAt(index) : 通过他的索引来获取元素

@Test
public void test1(){
String a="dfjkdjfd134";
for(int i=0;i<a.length();i++){
System.out.print(a.charAt(i)+" ");
} }
答案:d f j k d j f d 1 3 4

2  indexOf(String s) : 返回当前字符串的索引,字符串索引的位置从0开始

  indexOf(String s,int startpoint) 方法是从当前字符串的startpoint位置开始索引字符串s

String tom="I am a good cat"indexOF(String;
tom.indexOf("a"); // 值是2
tom.indexOf("good",); //值是7
tom.indexOf("a",); //值是13
tom.index.of("w",); //值是-1

String类中一些常用的函数的更多相关文章

  1. String类中常用的操作

    一.获取: 1.获取字符串的长度(注意是方法,不是跟数组的属性一样的) int length(); 1 public static void getLength(){ 2 String s = &qu ...

  2. string类中getline函数的应用

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhe ...

  3. java面向对象中的String类中12种常用的方法

    1.字符串与字符数组的转换 字符串可以使用toCharArray()方法变成一个字符数组,也可以使用String类的构造方法把一个字符数组变成一个字符串. public class StringAPI ...

  4. EL表达式 JSTL中的常用EL函数 动态数据的国际化

    ELppt: EL 全名为Expression Language.EL主要作用: 获取数据: •EL表达式主要用于替换JSP页面中的脚本表达式,以从各种类型的web域 中检索java对象.获取数据.( ...

  5. 基类中定义的虚函数在派生类中重新定义时,其函数原型,包括返回类型、函数名、参数个数、参数类型及参数的先后顺序,都必须与基类中的原型完全相同 but------> 可以返回派生类对象的引用或指针

      您查询的关键词是:c++primer习题15.25 以下是该网页在北京时间 2016年07月15日 02:57:08 的快照: 如果打开速度慢,可以尝试快速版:如果想更新或删除快照,可以投诉快照. ...

  6. String 类上的常用操作

    java 中String 类上的常用操作: 首先创建对象  String line = new String("String demo"); String line2 = new ...

  7. Java String类中的intern()方法

    今天在看一本书的时候注意到一个String的intern()方法,平常没用过,只是见过这个方法,也没去仔细看过这个方法.所以今天看了一下.个人觉得给String类中加入这个方法可能是为了提升一点点性能 ...

  8. 在C++的类中,普通成员函数不能作为pthread_create的线程函数,如果要作为pthread_create中的线程函数,必须是static

    在C++的类中,普通成员函数不能作为pthread_create的线程函数,如果要作为pthread_create中的线程函数,必须是static ! 在C语言中,我们使用pthread_create ...

  9. Java——String类中的compareTo方法总结

    String类的定义:    java.lang  类 String   java.lang.Object      java.lang.String 所有已实现的接口:Serializable, C ...

随机推荐

  1. jetbrain phpstorm 增加或删除一个 live template

    打开\.PhpStorm2016.2\config\templates 将xml文件放入该文件夹中 重启! 单独: setting -> editor -> Live Template +

  2. ios开发判断手机是否安装微信app

    1.代码如下 if ([WXApi isWXAppInstalled]) 2.如果以上代码无效,请在plist文件中添加如下内容

  3. epoll完整例子

    #include <deque> #include <map> #include <vector> #include <pthread.h> #incl ...

  4. PowerTool(杀毒辅助工具) V4.6 中文免费绿色版

    软件名称: PowerTool(杀毒辅助工具)软件语言: 简体中文授权方式: 免费软件运行环境: Win7 / Vista / Win2003 / WinXP 软件大小: 968KB图片预览: 软件简 ...

  5. E - Cup 2(dfs)

    E - Cup 2 Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Stat ...

  6. Linux安装mysql mysql5.5.40 <NIOT>

    一.    操作系统与软件 操作系统及版本 Centos 6.4 依赖包 gcc.gcc-c++.cmake.ncurses-devel 下载目录 /opt Mysql安装目录 /usr/local/ ...

  7. 生成元(Digit Generator,ACM/ICPC Seoul 2005,UVa 1583)

    #include<cstdio>#include<cstdlib>#include<cstring>using namespace std;int t, n, a, ...

  8. libimobiledevice命令

    Mac 安装 1. 安装HomeBrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/m ...

  9. hdu1016

    #include <stdio.h>#include <string.h> int prime[38]={0,0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1 ...

  10. [妙味Ajax]第三课:AJAX跨域解决方案:JSONP

    知识点总结: JSONP(JSON with Padding): 1.script标签 2.用script标签加载资源是没有跨域问题的 在资源加载进来之前定义好一个函数,这个函数接收一个参数(数据), ...