java分析成绩单实验报告_Java实验报告(三)及总结

实验三 String类的应用

一、 实验目的

(1) 掌握类String类的使用;

(2) 学会使用JDK帮助文档;

二、 实验内容

① 统计该字符串中字母s出现的次数。

② 统计该字符串中子串“is”出现的次数。

③ 统计该字符串中单词“is”出现的次数。

④ 实现该字符串的倒序输出。

实验代码:

packagecom.company;public classMain {public static voidmain(String[] args){int count=0,count1=0,count2=0;

String ch="this is a test of java";char[] c=ch.toCharArray();for(int i=0;i

count++;

}if(c[i]==i&&c[i+1]==s){

count1++;if(c[i-1]== &&c[i+2]== ){

count2++;

}

}

}

System.out.println("字符串中字母s出现的次数:"+count);

System.out.println("字符串中字串“is”出现

实验三 String类的应用 一、 实验目的 (1) 掌握类String类的使用; (2) 学会使用JDK帮助文档; 二、 实验内容 ① 统计该字符串中字母s出现的次数。 ② 统计该字符串中子串“is”出现的次数。 ③ 统计该字符串中单词“is”出现的次数。 ④ 实现该字符串的倒序输出。 实验代码: packagecom.company;public classMain {public static voidmain(String[] args){int count=0,count1=0,count2=0; String ch="this is a test of java";char[] c=ch.toCharArray();for(int i=0;i count++; }if(c[i]==i&&c[i+1]==s){ count1++;if(c[i-1]== &&c[i+2]== ){ count2++; } } } System.out.println("字符串中字母s出现的次数:"+count); System.out.println("字符串中字串“is”出现
经验分享 程序员 微信小程序 职场和发展