【leetcode】java String.charAt()
来源:互联网 发布:西安软件公寓地址 编辑:程序博客网 时间:2024/05/19 07:11
描述:以下是声明java.lang.String.charAt()方法java.lang.String.charAt()
方法返回指定索引处的char值。索引范围是从0到length()- 1。即:String str = "abcd", str.charAt(0)为a。
对于数组索引,序列的第一个char值是在索引为0,索引1,依此类推,
toCharArray:字符串转化成字符数组 char[] arr = str.toCharArray()
参数public char charAt(int index)
index -- 这是该指数的char值.
此方法返回这个字符串的指定索引处的char值。第一个char值的索引为0.
IndexOutOfBoundsException -- 如果index参数为负或不小于该字符串的长度.
package com.yiibai;下面的示例演示使用的java.lang.String.charAt()方法.
import java.lang.*;public class StringDemo { public static void main(String[] args) { String str = "This is yiibai"; // prints character at 1st location System.out.println(str.charAt(0)); // prints character at 5th location i.e white-space character System.out.println(str.charAt(4)); // prints character at 18th location System.out.println(str.charAt(17)); }}
让我们编译和运行上面的程序,这将产生以下结果。它也会打印空白字符。
Tp
0 0
- 【leetcode】java String.charAt()
- Java String charAt()方法
- java.lang.String-firstMethod-charAt()
- java.lang.String.charAt() 方法
- String.charAt()
- java--charAt()
- String charAt()、charCodeAt()、fromCharCode()方法
- android String.charAt的使用
- Java charAt() 方法
- charAt
- charAt()
- JAVA中的charAt()和toCharArray()
- 005 str.charAt(int) str.indexOf(String)
- C#:String类型中的CharAt 方法
- WHY IE AGAIN? - string.charAt(x) or string[x]?
- [Leetcode] Scramble String (Java)
- [Leetcode] Interleaving String (Java)
- Scramble String LeetCode JAVA
- 11082 - Matrix Decompressing (网络流建模|二分图匹配)
- Constructing Roads
- 5416 CRB and Tree
- autolayout - sizeClass - Masonry - 6
- Java中的内存泄露
- 【leetcode】java String.charAt()
- mysql的备份与恢复
- 简单的Thread
- 有return的情况下try catch finally的执行顺序(最有说服力的总结)
- lamp建
- HDU-1166敌兵布阵
- 第五章 引用类型
- POJ 2528 线段树+离散化(水水的线段树+略复杂的离散化)
- ADT升级到23出错,卸载旧版本ADT时出错Cannot complete the install because of a conflicting dependency.