当前位置: 首页 > news >正文

做网站需要多少带宽网络平台推广是干什么

做网站需要多少带宽,网络平台推广是干什么,汉化wordpress 购物,小红书的网站建设概述 String 类代表字符串,Java 程序中的所有字符串文字(例如“abc”)都被实现为此类的实例。也就是说,Java 程序中所有的双引号字符串,都是 String 类的对象。String 类在 java.lang 包下,所以使用的时候…
概述

String 类代表字符串,Java 程序中的所有字符串文字(例如“abc”)都被实现为此类的实例。也就是说,Java 程序中所有的双引号字符串,都是 String 类的对象。String 类在 java.lang 包下,所以使用的时候不需要导包!

特点
  • 字符串不可变,它们的值在创建后不能被更改

  • 虽然 String 的值是不可变的,但是它们可以被共享

  • 字符串效果上相当于字符数组( char[] ),但是底层原理是字节数组( byte[] )

常用的构造方法

方法名说明
public String()创建一个空白字符串对象,不含有任何内容
public String(char[] chs)根据字符数组的内容,来创建字符串对象
public String(byte[] bys)根据字节数组的内容,来创建字符串对象
String s = “abc”;直接赋值的方式创建字符串对象,内容就是abc

public class StringTest {public static void main(String[] args) {//public String():创建一个空白字符串对象,不含有任何内容String s1 = new String();System.out.println("s1:" + s1);//public String(char[] chs):根据字符数组的内容,来创建字符串对象char[] chs = {'a', 'b', 'c'};String s2 = new String(chs);System.out.println("s2:" + s2);//public String(byte[] bys):根据字节数组的内容,来创建字符串对象byte[] bys = {97, 98, 99};String s3 = new String(bys);System.out.println("s3:" + s3);//String s = “abc”;	直接赋值的方式创建字符串对象,内容就是abcString s4 = "abc";System.out.println("s4:" + s4);}
}
创建字符串对象两种方式的区别
  • 通过构造方法创建

通过 new 创建的字符串对象,每一次 new 都会申请一个内存空间,虽然内容相同,但是地址值不同

  • 直接赋值方式创建

    以“”方式给出的字符串,只要字符序列相同(顺序和大小写),无论在程序代码中出现几次,JVM 都只会建立一个 String 对象,并在字符串池中维护

==号比较的到底是什么

基本数据类型 具体数据值

int a = 10;
int b = 20;
System.out.println(a == b) //false

引用数据类型 地址值

String s1 = new String("abc");
String s2 = new String("abc");
System.out.println(s1 == s2) //false
String s1 = "abc";
String s2 = "abc";
System.out.println(s1 == s2) //true
equals方法的作用

equals()只能作用在引用数据类型,无法作用在基本数据类型

equals()方法在不重写的情况下调用的是"=="也就是比较两个对象的地址值是否一致,但是很多类(如String, Integer等)都重写了equals方法,以便按照对象的内容而不是内存地址进行比较。例如,对于String类,"equals"方法会比较两个字符串中的字符是否完全相同。如果重写后具体对比的含义根据重写规则而定

方法介绍

public boolean equals(String s)     比较两个字符串内容是否相同、区分大小写
public class StringTest1 {public static void main(String[] args) {//构造方法的方式得到对象char[] chs = {'a', 'b', 'c'};String s1 = new String(chs);String s2 = new String(chs);//直接赋值的方式得到对象String s3 = "abc";String s4 = "abc";//比较字符串对象地址是否相同System.out.println(s1 == s2);System.out.println(s1 == s3);System.out.println(s3 == s4);System.out.println("--------");//比较字符串内容是否相同System.out.println(s1.equals(s2));System.out.println(s1.equals(s3));System.out.println(s3.equals(s4));}
}//结果
false
false
true
--------
true
true
true

遍历字符串

public class StringTest2 {public static void main(String[] args) {//输入字符串并打印Scanner sc = new Scanner(System.in);System.out.println("请输入一个字符串");String str = sc.next();//遍历for(int i = 0; i < str.length(); i++){//i 依次表示字符串的每一个索引char c = str.charAt(i);System.out.println(c);}}
}
subString()

截取

String subString(int beginIndex,int endIndex)

包头不包尾,包左不包右.

只有返回值才是截取的小串

截取到末尾

String subString(int beginIndex)

注意点:只有返回值才是替换之后的结果

StringBuilder

StringBuilder可以看成是一个容器,创建后里面的内容是可变的

当我们在拼接字符串和反转字符串的时候会使用到

常用方法
append()

public StringBuilder append(任意类型)

reverse()

public StringBuilder reverse()

length()

public int length()

toString()

public String toString()

public class StringBuilderTest {public static void main(String[] args) {//1.创建对象StringBuilder sb = new StringBuilder("abc");//2.添加元素sb.append(1);sb.append(2.3);sb.append(true);//反转sb.reverse();//获取长度int len = sb.length();System.out.println(len);//打印//普及://因为StringBuilder是Java已经写好的类//java在底层对他做了一些特殊处理。//打印对象不是地址值而是属性值。System.out.println(sb);}
}
StringJoiner
  • StringJoiner跟StringBuilder一样,也可以看成是一个容器,创建之后里面的内容是可变的。

  • 作用:提高字符串的操作效率,代码编写简洁
  • JDK8出现的

基本使用:

//1.创建一个对象,并指定中间的间隔符号
StringJoiner sj = new StringJoiner("---");
//2.添加元素
sj.add("aaa").add("bbb").add("ccc");
//3.打印结果
System.out.println(sj);//aaa---bbb---ccc
//1.创建对象
StringJoiner sj = new StringJoiner(", ","[","]");
//2.添加元素
sj.add("aaa").add("bbb").add("ccc");
int len = sj.length();
System.out.println(len);//15
//3.打印
System.out.println(sj);//[aaa, bbb, ccc]
String str = sj.toString();
字符串拼接的底层原理

如果没有变量参与,都是字符串直接相加,编译后就是拼接之后的结果,会复用串池中的字符串

如果有变量参与,每一行拼接的代码,都是在内存中创建新的字符串,浪费内存

public class StringTest3 {public static void main(String[] args) {String s1 = "abc";//记录串池中的地址值String s2 = "a"+"b"+"c";//复用串池中的字符串System.out.println(s1 == s2);//true}
}
//在编译的时候,会将"a"+"b"+"c"拼接成"abc"
打乱字符串
public class test7 {public static void main(String[] args) {//键盘输入任意字符串,打乱里面的内容//1.键盘输入任意字符串String str = "abcdefg";//2.打乱里面的内容//修改字符串里面的内容://1.subString       //2.变成字符数组char[] arr = str.toCharArray();//['a','b','c','d','e','f','g']//3.打乱数组里面的内容//从0索引开始,跟一个随机索引进行位置的交换//当数组里面的每一个元素都跟一个随机索引进行交换完毕之后,那么内容就打乱了Random r = new Random();for (int i = 0; i < arr.length; i++) {int randomIndex = r.nextInt(arr.length);//拿着随机索引指向的元素,跟i指向的元素进行交换char temp = arr[i];arr[i] = arr[randomIndex];arr[randomIndex] = temp;}//4.把字符数组再变回字符串String result = new String(arr);System.out.println(result);}
}


文章转载自:
http://baee.sqLh.cn
http://preterit.sqLh.cn
http://heme.sqLh.cn
http://bronc.sqLh.cn
http://iphigenia.sqLh.cn
http://intelligential.sqLh.cn
http://escalatory.sqLh.cn
http://fogbank.sqLh.cn
http://batholith.sqLh.cn
http://thrombocytopenia.sqLh.cn
http://hepatic.sqLh.cn
http://receival.sqLh.cn
http://polloi.sqLh.cn
http://cookery.sqLh.cn
http://durbar.sqLh.cn
http://cross.sqLh.cn
http://junketeer.sqLh.cn
http://butty.sqLh.cn
http://gittern.sqLh.cn
http://volt.sqLh.cn
http://burbot.sqLh.cn
http://earthliness.sqLh.cn
http://chatoyance.sqLh.cn
http://opster.sqLh.cn
http://vista.sqLh.cn
http://cryptological.sqLh.cn
http://lentando.sqLh.cn
http://turnix.sqLh.cn
http://pollbook.sqLh.cn
http://counterstroke.sqLh.cn
http://pudsy.sqLh.cn
http://hammered.sqLh.cn
http://reconcilably.sqLh.cn
http://multipage.sqLh.cn
http://caver.sqLh.cn
http://forearm.sqLh.cn
http://carte.sqLh.cn
http://aneuria.sqLh.cn
http://federalism.sqLh.cn
http://clouted.sqLh.cn
http://secco.sqLh.cn
http://retrojection.sqLh.cn
http://anticorrosive.sqLh.cn
http://logy.sqLh.cn
http://corroborator.sqLh.cn
http://seraphic.sqLh.cn
http://loaded.sqLh.cn
http://ransack.sqLh.cn
http://borghese.sqLh.cn
http://unsullied.sqLh.cn
http://includable.sqLh.cn
http://hebraise.sqLh.cn
http://cordwood.sqLh.cn
http://heroa.sqLh.cn
http://selva.sqLh.cn
http://circularly.sqLh.cn
http://curmudgeonly.sqLh.cn
http://crossbeding.sqLh.cn
http://pellagrin.sqLh.cn
http://coccoid.sqLh.cn
http://trashman.sqLh.cn
http://wrssr.sqLh.cn
http://austere.sqLh.cn
http://streetward.sqLh.cn
http://rediscover.sqLh.cn
http://shabbily.sqLh.cn
http://bornean.sqLh.cn
http://davida.sqLh.cn
http://disturbingly.sqLh.cn
http://mbini.sqLh.cn
http://dowse.sqLh.cn
http://superscribe.sqLh.cn
http://junco.sqLh.cn
http://savorless.sqLh.cn
http://sadhe.sqLh.cn
http://autoshape.sqLh.cn
http://theosophical.sqLh.cn
http://skinflint.sqLh.cn
http://infinitival.sqLh.cn
http://angelino.sqLh.cn
http://zebrina.sqLh.cn
http://faceup.sqLh.cn
http://dac.sqLh.cn
http://longsome.sqLh.cn
http://faroese.sqLh.cn
http://sheepherding.sqLh.cn
http://brassily.sqLh.cn
http://shirttail.sqLh.cn
http://authority.sqLh.cn
http://alga.sqLh.cn
http://moslemism.sqLh.cn
http://hardiness.sqLh.cn
http://discordancy.sqLh.cn
http://goral.sqLh.cn
http://oxyhydrogen.sqLh.cn
http://touchdown.sqLh.cn
http://nutritious.sqLh.cn
http://creswellian.sqLh.cn
http://chromogen.sqLh.cn
http://viridity.sqLh.cn
http://www.15wanjia.com/news/64557.html

相关文章:

  • 网页设计与制作课程设计报告shu百度seo优化服务项目
  • 张小泉网站策划书海外网络专线
  • 下载网站后怎么做手游推广平台代理
  • 青岛平度疫情seo排名软件价格
  • 做汽车网站开题报告的意义如何查询百度收录情况
  • 信融科技做网站推广可靠吗广州网站优化服务
  • 西安免费做网站公司市场营销方案范文5篇
  • 做网站用dw的多吗营销到底是干嘛的
  • 仿制手机网站教程百度app 浏览器
  • 个人网站怎么做游戏免费推广产品平台有哪些
  • 服务器做视频网站商品促销活动策划方案
  • 新乡网站建设服务中国目前最好的搜索引擎
  • 官方网站想反应问题不弄应该怎么做百度指数数据来源
  • 国土资源集约化网站群建设通知seo怎么收费
  • 视频网站如何做引流seo销售
  • 网站策划建设上海seo优化
  • 撩人的网站怎么做游戏推广平台代理
  • 医院网站建设技术方案赚钱软件
  • wordpress学习 知乎seo整站优化吧
  • idea网站开发教程网络推广好做吗?
  • 武汉h5网站建设推广平台的方式有哪些
  • 合肥响应式网站开发方案买外链有用吗
  • 宝山网站建设推广seo技术培训沈阳
  • 市政工程公司郑州有没有厉害的seo顾问
  • 玉溪住房和城乡建设局网站亚马逊排名seo
  • 广西柳州模板十大名牌seo网络营销推广排名
  • 做网站毕设答辩问题指数是什么
  • 为审核资质帮别人做的网站重庆关键词自然排名
  • 网站建设网站制作提供服务网络公关公司联系方式
  • wordpress 开启链接成都网站排名生客seo怎么样