java 数组 ppt_java字符串及数组.ppt

public char charAt(int?index) 返回指定索引处的 char 值。索引范围为从 0 到 length() - 1。序列的第一个 char 值在索引 0 处,第二个在索引 1 处,依此类推,这类似于数组索引。 public boolean equalsIgnoreCase(String?anotherString) 将此 String 与另一个 String 进行比较,不考虑大小写。如果两个字符串的长度相等,并且两个字符串中的相应字符都相等(忽略大小写),则认为这两个字符串是相等的。 public String concat(String?str) 将指定字符串联到此字符串的结尾。 如果参数字符串的长度为 0,则返回此 String 对象。否则,创建一个新的 String 对象,用来表示由此 String 对象表示的字符序列和由参数字符串表示的字符序列串联而成的字符序列。 “Hello, “.concat(“ java”).concat(“ World!”) “Hello” +” java”+” World” class IenString { public static void main(String args[]) { int index=-1,length=0,n=0; String str="我非常喜欢1236" ; index=【代码1】 //str调用方法返回"1236"在str出现的位置 length=【代码2】 //str调用方法返回str中字符的个数 String temp=【代码3】 //str调用方法返回字符串"1236" n=【代码4】 //将temp转化为int型数据。 System.out.println(n); } } 【代码1】 【代码2】 【代码3】 【代码4】 * class Example5_4 { public static void main(String args[]) { String path="c:\\myfile\\2000\\result.txt"; int index=path.lastIndexOf("\\"); String fileName=path.substring(index+1); String newName=fileName.replaceAll(".txt",".java"); System.out.println(path); System.out.println(fileName); System.out.println(newName); } } * public class Example5_5 { public static void main(String args[]) { double n,sum=0,item=0; boolean computable=true; for(int i=0;i

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值