云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 实验七 常用实用类

实验七 常用实用类

  • 62 次阅读
  • 3 次下载
  • 2026/4/23 14:36:15

}

result=//【代码4】//n1和n2做除法运算 System.out.println(\商:\BigInteger m=new BigInteger(\

COUNT=new BigInteger(\ ONE=new BigInteger(\ TWO=new BigInteger(\

System.out.println(m.toString()+\的因子有:\

for(BigInteger i=TWO;i.compareTo(m)<0;i=i.add(ONE)){ if((n1.remainder(i).compareTo(BigInteger.ZERO))==0){

COUNT=COUNT.add(ONE);

System.out.print(\ \ } } }

System.out.println(\

System.out.println(m.toString()+\一共有\个因子\

实验5 替换IP

模板代码

ReplaceErrorWord.java

import java.util.regex.Matcher; import java.util.regex.Pattern; public class ReplaceErrorWord { }

public static void main(String[] args) { }

String str=\登录网站:222.128.89.253\Pattern pattern; Matcher matcher;

String regex=\pattern=//【代码1】//使用regex初始化模式对象pattern matcher=//【代码2】//得到检索str的匹配对象matcher String IP=\while(matcher.find()){ }

System.out.printf(\将%s替换为202.192.78.56\\n\String result=matcher.replaceAll(\System.out.println(result);

IP=matcher.group();

System.out.print(matcher.start()+\位置出现:\System.out.println(IP);

实验6 String类的常用方法

模板代码

StringExample.java

class StringExample

{ public static void main(String args[])

{ String s1=new String(\ s2=new String(\

if(【代码1】) // 使用equals方法判断s1与s2是否相同 {

System.out.println(\与s2相同\ } else {

System.out.println(\与s2不相同\ }

String s3=new String(\

if(【代码2】) //判断s3的前缀是否是“220302”。 {

System.out.println(\吉林省的身份证\ }

String s4=new String(\你\ s5=new String(\我\

if(【代码3】)//按着字典序s4大于s5的表达式。 {

System.out.println(\按字典序s4大于s5\ } else {

System.out.println(\按字典序s4小于s5\ }

int position=0;

String path=\

position=【代码5】 //获取path中最后出现目录分隔符号的位置 System.out.println(\中最后出现\\\\的位置:\ String fileName=【代码6】//获取path中“A.java”子字符串。 System.out.println(\中含有的文件名:\ String s6=new String(\ s7=new String(\

int n1=【代码7】 //将s6转化成int型数据。 double n2=【代码8】 //将s7转化成double型数据。 double m=n1+n2; System.out.println(m);

String s8=【代码9】 //String调用valuOf(int n)方法将m转化为字符串对象 position=s8.indexOf(\

String temp=s8.substring(position+1);

System.out.println(\数字\有\位小数\ String s9=new String(\

char a[]=【代码10】 //将s8存放到数组a中。 for(int i=a.length-1;i>=0;i--) {

System.out.print(\ } } }

搜索更多关于: 实验七 常用实用类 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

} result=//【代码4】//n1和n2做除法运算 System.out.println(\商:\BigInteger m=new BigInteger(\ COUNT=new BigInteger(\ ONE=new BigInteger(\ TWO=new BigInteger(\ System.out.println(m.toString()+\的因子有:\ for(BigInteger i=TWO;i.compareTo(m)<0;i=i.add(ONE)){ if((n1.remainder(i).compareTo(BigInteger.ZERO))

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com