博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java StringBuffer char charAt(int index)方法与示例
阅读量:2535 次
发布时间:2019-05-11

本文共 1881 字,大约阅读时间需要 6 分钟。

StringBuffer类char charAt(int index) (StringBuffer Class char charAt(int index))

  • This method is available in package java.lang.StringBuffer.charAt(int index).

    软件包java.lang.StringBuffer.charAt(int index)中提供了此方法。

  • This method is used to return the character value at the specified index in the method.

    此方法用于返回方法中指定索引处的字符值。

  • This method raises IndexOutOfBoundsException if the given index is negative or greater than the length of the StringBuffer object.

    如果给定的索引为负或大于StringBuffer对象的长度,则此方法引发IndexOutOfBoundsException 。

Syntax:

句法:

char charAt(int index){    }

Parameter(s):

参数:

We can pass only one object in the method of the StringBuffer i.e index.

我们只能在StringBuffer的方法(即索引)中传递一个对象。

Return value:

返回值:

The return type of this method is char that means this method return a character at the given index.

该方法的返回类型为char ,这意味着该方法在给定索引处返回一个字符。

Java程序演示charAt(int index)方法的示例 (Java program to demonstrate example of charAt(int index) method)

import java.lang.StringBuffer;public class StringBufferClass {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer("Java is a programming language : "); // use charAt(int index) it will return character at the specified index // Display result after implementing charAt(2) System.out.println("The result will be after implementing method charAt(2) is :" + sb.charAt(2)); sb = new StringBuffer("Java Support OOPS Concept"); // use charAt(int index) it will return character at the specified index // Display result after implementing charAt(5) System.out.println("The result will be after implementing method charAt(5) is :" + sb.charAt(5)); }}

Output

输出量

D:\Programs>javac StringBufferClass.javaD:\Programs>java StringBufferClassThe result will be after implementing method charAt(2) is :vThe result will be after implementing method charAt(5) is :S

翻译自:

转载地址:http://dbazd.baihongyu.com/

你可能感兴趣的文章
录制游戏视频——fraps
查看>>
jQuery 停止动画
查看>>
HTML基础之JS
查看>>
01背包问题python 2.7实现
查看>>
E - Kagome Kagome
查看>>
Android Studio Errors
查看>>
软件工程第二次作业—结对编程
查看>>
【字符编码】Java字符编码详细解答及问题探讨
查看>>
学习操作系统导图
查看>>
在线的JSON formate工具
查看>>
winform非常实用的程序退出方法!!!!!(转自博客园)
查看>>
xml解析
查看>>
centos安装vim
查看>>
linux工作调度(计划任务)
查看>>
HTTP协议形象展现
查看>>
hdu--1698 Just a Hook(线段树+区间更新+懒惰标记)
查看>>
Django 框架的 模板继承 与 模板包含
查看>>
Effective Modern C++:01类型推导
查看>>
根据html页面模板动态生成html页面(c#类)
查看>>
Failed to Connect to MySQL at 127.0.0.1:3306 MySql WorkBench 本地连接问题
查看>>