miluframe({ /*个人链接地址*/ Youself:'https://www.cnblogs.com/miluluyo/', /*导航栏信息*/ custom:[{ name:'留言板', link:'https://www.cnblogs.com/miluluyo/p/11578505.html', istarget:false },{ name:'技能树', link:'https://miluluyo.github.io/', istarget:true }], /*自己的友链页面后缀*/ Friends_of_the:'p/11633791.html', /*自己的友链信息*/ resume:{ "name":"麋鹿鲁哟", "link":"https://www.cnblogs.com/miluluyo", "headurl":"https://images.cnblogs.com/cnblogs_com/elkyo/1558759/o_o_my.jpg", "introduction":"大道至简,知易行难。" }, /*友链信息*/ unionbox:[{ "name":"麋鹿鲁哟", "introduction":"生活是没有标准答案的。", "url":"https://www.cnblogs.com/miluluyo", "headurl":"https://images.cnblogs.com/cnblogs_com/elkyo/1558759/o_o_my.jpg" },{ "name":"麋鹿鲁哟的技能树", "introduction":"大道至简,知易行难。", "url":"https://miluluyo.github.io/", "headurl":"https://images.cnblogs.com/cnblogs_com/elkyo/1558759/o_o_my.jpg" }], /*点击页面时候的弹出文本显示*/ clicktext:new Array("ヾ(◍°∇°◍)ノ゙加油哟~ ——麋鹿鲁哟","生活是没有标准答案的。 ——麋鹿鲁哟"), /*github链接*/ githuburl:'https://github.com/miluluyo' })

2022.07.20 第三小组 陈迪 学习笔记

string常用方法:

string是一个类,string一旦声明不可改变!!!(内存级别)

类中可以有哪些结构?

​ 属性,方法,构造器

​ string有三十多个方法,需要掌握15个以上

​ s1叫做string类的对象,成员变量(属性),局部变量(变量)
​ 类如果创建对象,用到new,s1并没有new,s1也可以叫做对象

​ 常量不会在堆里,new的值会在堆里

​ s2是通过new创建出来的string类的对象
​ 创建对象是要调用构造器

​ s1指向的"asdf"和s2指向的"asdf"不在同一个区域
​ 双等号比较的是虚地址
​ 虚地址:对象在内存中的存储位置
​ new代表新建

​ 除了手写的=赋值,其余都是new赋值

​ =赋值,无论怎么比较,都是true

​ new赋值,用==比较,是false

public static void main(String[] args) {
    String s1="qwer";
    String s2=new String("qwer");
    String s3=new String("qwer");
    String s4="qwer";
    System.out.println(s3==s2);
    System.out.println(s1==s4);
}

image-20220720090329564

1.1、equals:

​ 1、需要传参,传string类型的参数
​ 2、有返回值,返回值是boolean类型
​ 3、访问权限public

==地址比较

equals值比较

1.2、长度:

​ 字符串 字符拼成的串
length方法:
​ 1、不需要传参
​ 2、有返回值,整型int
​ 3、访问权限public
​ 字符串获取长度和数组获取长度的区别:
​ 1、数组的length是属性,字符串的length()是方法

1.3、取出指定下标位置的字符:

String s1="asdf";
System.out.println(s1.charAt(0));
Scanner sc=new Scanner(System.in);
char c=sc.next().charAt(0);
System.out.println(c);

1.4、判断指定字符是否存在:

​ 返回值为字符串在s1的下标
​ 返回从左至右遇到的第一个匹配的下标
​ indexof(String,int)代表从int位置开始查找,包括当前位置
​ s1.lastIndexOf(String)从后往前找
​ 如果不存在,返回-1

System.out.println(s1.indexOf("a",3));
System.out.println(s1.lastIndexOf("a"));

1.5、字符串的截取:

​ 如果传一个参数,从指定位置开始截取,直到字符串的末尾
​ 包括起始位置的字符,不包括终止位置的字符
​ 生成一个新的字符串,不会改变原有数据

String c=str.substring(1);
System.out.println(c);

1.6、其余方法:

转大写
System.out.println(str.toUpperCase());
转小写
System.out.println(str.toLowerCase());
判断是否以xxxx开头
System.out.println(str.startsWith("a",4));
判断是否以xxxx结尾
System.out.println(str.endsWith("f"));
忽略大小写进行比较内容
System.out.println(str.equalsIgnoreCase(str1));
去掉字符串前后的空格
System.out.println(str.trim());
根据指定的字符分割,分割后,分隔条件是消失
String[]strings=str1.split("s");
System.out.println(Arrays.toString(strings));

心得体会:

今天学习了string中的一些方法,今天内容比较容易理解,不是很难,但对于管理系统编程中方法调用以及参数传递理解较难,还是不会,还需要进一步努力学习。

posted @ 2022-07-20 19:15  jinjidecainiao  阅读(32)  评论(0)    收藏  举报
@media only screen and (max-width: 767px){ #sidebar_search_box input[type=text]{width:calc(100% - 24px)} } L2Dwidget.init({ "model": { jsonPath: "https://unpkg.com/live2d-widget-model-hijiki/assets/hijiki.model.json", "scale": 1 }, "display": { "position": "left", "width": 100, "height": 200, "hOffset": 70, "vOffset": 0 }, "mobile": { "show": true, "scale": 0.5 }, "react": { "opacityDefault": 0.7, "opacityOnHover": 0.2 } }); window.onload = function(){ $("#live2dcanvas").attr("style","position: fixed; opacity: 0.7; left: 70px; bottom: 0px; z-index: 1; pointer-events: none;") } 参数说明 名称 类型 默认值/实例 描述Youself 字符串 https://www.cnblogs.com/miluluyo/ 个人博客园首链接 custom 数组 [{ name:'相册', link:'https://www.cnblogs.com/elkyo/gallery.html', istarget:false },{ name:'技能树', link:'https://miluluyo.github.io/', istarget:true },{ name:'留言板', link:'https://miluluyo.github.io/p/11578505.html', istarget:false }] 导航信息 name 导航名 link 导航链接 istarget true跳转到新页面上,false当前页面打开 Friends_of_the 字符串 11633791 友链文章的后缀名,若字符串为空则不显示友链 resume 对象 { "name":"麋鹿鲁哟", "link":"https://www.cnblogs.com/miluluyo/", "headurl":"https://images.cnblogs.com/cnblogs_com/ elkyo/1558759/o_o_my.jpg", "introduction":"大道至简,知易行难。" } 自己的友链信息 name 导航名 link 导航链接 headurl 头像 introduction 语录 unionbox 数组 [{ "name":"麋鹿鲁哟", "introduction":"生活是没有标准答案的。", "url":"https://www.cnblogs.com/miluluyo", "headurl":"https://images.cnblogs.com/cnblogs_com/ elkyo/1558759/o_o_my.jpg" },{ "name":"麋鹿鲁哟的技能树", "introduction":"大道至简,知易行难。", "url":"https://miluluyo.github.io/", "headurl":"https://images.cnblogs.com/cnblogs_com/ elkyo/1558759/o_o_my.jpg" }] 友链数组 name 昵称 introduction 标语 url 链接地址 headurl 头像地址 clicktext 新数组 new Array("ヾ(◍°∇°◍)ノ゙加油哟~ ——麋鹿鲁哟", "生活是没有标准答案的。 ——麋鹿鲁哟"), 点击页面时候的弹出显示 githuburl 字符串 https://github.com/miluluyo github链接