zoukankan      html  css  js  c++  java
  • java-string类

    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?

  • 相关阅读:
    android sdk配置
    ptmalloc, dlmalloc
    Longest common subsequence problem
    handless UI (direct UI)
    poj 题目分类
    2010有道难题练习赛2
    JAVA内存模型
    wxformbuilder+WxWidgets下载编译使用
    这几天弄一下
    活用regex的例子 zz
  • 原文地址:https://www.cnblogs.com/wenwangt/p/4899172.html
Copyright © 2011-2022 走看看