⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringdemo.java~5~

📁 jbuilder2006一书的所有源代码
💻 JAVA~5~
字号:
package string;public class StringDemo {  public static void main(String[] args) {    String s1 = "  String demo ";    String s2 = "Hello, This is a String Sample.";    String s3 = "hello, This is a String Sample.";    String s4 = "This is a String Sample.";    String s5 = "     Hello, This is a String Sample.";    System.out.println("下面演示字符串抽取方法的应用");    System.out.println("s1.charAt(7) = " + s1.charAt(7));    System.out.println("s1.substring(6) = " + s1.substring(6));    System.out.println("下面演示字符串比较方法的应用");    System.out.println("s1.equals(s2) = " + s1.equals(s2));    System.out.println("s1.equalsIgnoreCase(s3) = " + s1.equalsIgnoreCase(s3));    System.out.println("s1 == s2 = " + String.valueOf(s1 == s2));    System.out.println("s1.compareTo(s2) = " + s1.compareTo(s2));    System.out.println("s1.regionMatches(6,s4,0,s4.length()) = " +                       s1.regionMatches(6,s4,0,s4.length()));    System.out.println("下面演示字符串查找方法的应用");    System.out.println("s1.indexOf(str) = " + s1.indexOf("is"));    System.out.println("s1.indexOf(str,int) = " + s1.indexOf("This",0));    System.out.println("s1.indexOf(str,int) = " + s1.indexOf("is",20));    System.out.println("下面演示字符串长度方法的应用");    System.out.println("s1.length() = " + s1.length());    System.out.println("下面演示字符串替换方法的应用");    System.out.println("s1.replace('i','I') = " + s1.replace('i','I'));    System.out.println("下面演示字符串连接方法的应用");    System.out.println("s4.concat(s4) = " + s4.concat(s4));    System.out.println("s4+s5 = " + s4 + s5);    System.out.println("下面演示字符串首尾比较方法的应用");    System.out.println("s1.startWith() = " + s1.startsWith("Hello"));    System.out.println("s1.startWith() = " + s1.startsWith("T",8));    System.out.println("s1.endWith() = " + s1.endsWith("."));    System.out.println("下面演示字符串大小写转换方法的应用");    System.out.println("s1.toLowerCase() = " + s1.toLowerCase());    System.out.println("s1.toUpperCase() = " + s1.toUpperCase());    System.out.println("下面演示字符串首尾空格截取方法的应用");    System.out.println("s1.trim() = " + s5.trim());  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -