首页 > 编程语言 > 详细

java-string类

时间:2015-10-21 22:38:43      阅读:289      评论:0      收藏:0      [点我收藏+]
package com.example.helloworld;

/**
 * Created by carl on 10/21/15.
 */
public class StringChecker {
    public static void main(String[] arguments) {
        String str = "Would you like an apple pie with that?";
        System.out.println("This string is: " + str);
        System.out.println("Length of string is: " + str.length());
        System.out.println("The character at position 6:" + str.charAt(6));
        System.out.println("The substring from 26 to 28:" + str.substring(26, 28));
        System.out.println("The index of first a:" + str.indexOf(‘a‘));
        System.out.println("The index of the beginning of the :" + "substring \"with\" " + str.indexOf("with"));
        System.out.println("The substring in uppercase:" + str.toUpperCase());
    }
}

运行结果如下:

This string is: Would you like an apple pie with that?
Length of string is: 38
The character at position 6:y
The substring from 26 to 28:e
The index of first a:15
The index of the beginning of the :substring "with" 28
The substring in uppercase:WOULD YOU LIKE AN APPLE PIE WITH THAT?

java-string类

原文:http://www.cnblogs.com/wenwangt/p/4899172.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!