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

网站设计对网站搜索引擎友好性的影响中国培训网是国家公认的吗

网站设计对网站搜索引擎友好性的影响,中国培训网是国家公认的吗,完善网站建设通知,wordpress 分类 图像描述一(字符串String介绍): 字符串定义:由一连串字符组成不可变的字符序列。 字符串底层:final char value[],字符串底层是用char数组来存储。 String类的初始化:在操作String类之前,需要对Strin…

一(字符串String介绍):

字符串定义:由一连串字符组成不可变的字符序列。

字符串底层:final char value[],字符串底层是用char数组来存储。

String类的初始化:在操作String类之前,需要对String类进行初始化。在java中可以通过以下两种方式对String类进行初始化。

1.使用字符串常量直接初始化一个String对象,语法格式如:String 变量名=字符串;

String str1=null;//初始化为空String str2=""//初始化为空字符串String str3="abc"//初始化为abc,其中abc为字符串常量

2.使用String的构造方法初始化字符串对象,语法格式如:String 变量名=new String(字符串);

在上述语法中,字符串同样可以为空或者一个具体的字符串。当为具体的字符串时,会使用String类的不同参数类型的构造方法来初始化字符串对象。

String类的常用构造方法
方法声明功能描述
public String()创建的一个空白字符串对象,不包含任何内容
public String(char[ ] chs)根据字符数组的内容,创建字符串对象
public String(byte[] bys)根据字节数组的内容,创建字符串对象
  public String(String s) 根据具体字符串s创建字符串对象
package 字符串String;public class Demo1 {public static void main(String[] args) {//1.String str1=new String();String str2=null;//str2是没有对象指向的,所以不能通过str2调用任何方法,否则出空指针异常System.out.println(str1.equals(" "));//falseSystem.out.println(str1.equals("null"));//falseSystem.out.println(str1.equals(""));//true//System.out.println(str2.equals(null));//NullPointExecption//2.char[] chs={'1','t','g','5','h'};String str3=new String(chs);System.out.println("str3"+str3);//1tg5h//3.byte[] bys={97,98,99,100,101};String str4=new String(bys);System.out.println("str4:"+str4);//abcde,输出的由字节数组中每个数字对应字符拼接而成字符串int[] is={100,101,102,103};//offset偏移量:从哪里开始  count:多长String str5=new String(is,1,3);System.out.println(str5);//efg//4.String str6=new String("wdfg");System.out.println(str6);//wdfg}}

java的内存划分:堆,栈,方法区,本地方法栈,寄存器。

1.堆:凡是new出来的东西都放在堆当中。

2.栈:存放的都是方法中局部变量(方法的运行一定是在栈中运行的)局部变量:方法的参数,方法中内部的遍历。

3.方法区:存储.class相关信息,包含方法的信息,常量池()。常量池:通过字面量("abc")创建的String对象,都放在常量池中。常量池中不会存在相同内容的字符串对象。

4.本地方法栈:与操作系统相关。

5.寄存器:cpu相关。

eg:User u=new User();User  u是存储在栈里面,new User()是存储在堆里面。

package 字符串String;public class Demo {public static void main(String[] args) {String str1="abc";//char[]  value={'a','b','c'}String str2="abc";String str3=new String("abc");/*==:基本类型是用来判断两个值是否相等的引用类型是判断是否是同一个对象(比较的是地址)*/System.out.println(str1==str2);//trueSystem.out.println(str1==str3);//falseString str4="abc";str4+="def";//str4=str4+"def"System.out.println(str4);//abcdefString str5="abcdef";String str6="abc"+"def";//编译后:String str6="abcdef"System.out.println(str4==str1);//falseSystem.out.println(str5==str4);//"abcdef"和str4+"def"  falseSystem.out.println(str5==str6);//"abcdef"和"abcdef"    true}
}

 二(常用方法操作):

1.字符串比较方法equals(Object o)

Object是所有类的父类,String 和其他任意类型进行比较,比较字符串内容是否相同。

比较步骤:
             1.先比较地址是否相同
             2.判断传入的对象是否可以转成String,
                    如果不可以则直接return false
                    如果可以则,将传入的对象强转为String
             3.比较两个String类型的char数组的长度
                    如果长度不相同,直接return false
                    如果长度相同,依次比较两个数组的内容
                            内容有一个不相同,则直接return false
                            否则return true
比较的是:当前的String对象this,和传入进来的anObject对象

public boolean equals(Object anObject) {if (this == anObject) {//比较当前的this和anObject对象是否是同一个对象(比较两个对象地址是否相同)return true;//如果是同一个对象则返回true}if (anObject instanceof String) { //instanceof 判断anObject是否可以转成String//如果能转,将Object类型转为String,String anotherString = (String)anObject;//比较内容//1.先比较两个char数组的长度,int n = value.length;if (n == anotherString.value.length) {// 如果两个数组的长度相等,依次比较char数组的内容char v1[] = value;char v2[] = anotherString.value;int i = 0;while (n-- != 0) {if (v1[i] != v2[i])//比较内容return false;//内容不相同则直接return falsei++;}return true;}}return false;//如果不能转成String,直接return false//长度不相等}
public class StringDemo01 extends Object {public static void main(String[] args) {String str1="ABC";//"ABC"存在常量池String str2=new String("ABC");//new String 在堆中System.out.println("==判断:"+str1==str2);//==比较两个地址是否相同,所以不相同System.out.println("equals:"+str1.equals(str2));//str1的char数组和str2的char数组进行比较,trueSystem.out.println(str1.equals(new Student()));//false,类型不匹配}
}
class Student{}

2.字符串的获取

public int length();//获取字符串长度
public char charAt(int index);//获取指定索引(下标)处的字符(返回的char数组指定下标的值)
public int indexOf(int ch);//返回指定字符首次出现的位置
public int indexOf(int ch,int fromIndex)//返回指定字符从fromIndex开始首次出现的位置

      for(int i=fromIndex;i<max;i++){if(value[i]==ch){return i;}}


 public int indexOf(String str)//返回指定字符串首次出现的位置
 public int indexOf(String str,int fromIndex)//返回指定字符串从fromIndex开始首次出现的位置   public int lastIndexOf(int ch);//返回指定字符最后一次出现的位置
 public int lastIndexOf(int ch,int fromIndex)//返回指定字符从fromIndex开始,最后一次出现的位置
 public int lastIndexOf(String str)//返回指定字符串最后一次出现的位置
 public int lastIndexOf(String str,int fromIndex)//返回指定字符从fromIndex开始,最后一次出现的位置

public class StringDemo02 {public static void main(String[] args) {char[] chs=new char[10];System.out.println(chs.length);//数组长度属性String str="ABCDEFCDGHF";System.out.println(str.length());//字符串获取长度的方法System.out.println("index-3:"+str.charAt(3));System.out.println("C:"+str.indexOf('C'));System.out.println("C-fromIndex:"+str.indexOf('D',5));System.out.println("CD:"+str.indexOf("CD"));System.out.println("CD-fromIndex:"+str.indexOf("CD",5));//从5开始找第一次出现CD的位置System.out.println("CD-last"+str.lastIndexOf("CD"));//最后一次出现CD的位置System.out.println(str.lastIndexOf('F',6));char  c=10;//c表示是编码为10的字符char c2='D';//c2表示的D这个字符串}
}

 3.字符串的截取
        public String subString(int beginIndex)//从beginIndex截取到字符串末尾
        public String subString(int beginIndex,int endIndex)//从beginIndex截取到endIndex-1,包头不包尾
        public String trim();//去掉子串前后的空格,中间的空格不能去掉

package 字符串String;public class Demo3 {public static void main(String[] args) {String str=" QWE RCDF ";System.out.println(str.substring(3));////含头不含尾(包含下标为3的字符,不包含下标为5字符)System.out.println(str.substring(3,5));//取得是3 4 位置字符System.out.println("***"+str+"***");System.out.println("***"+str.trim()+"***");//urlString str1="http://www.baidu.com/long.do";String str2="http://www.taobao.com.cn";//截取taobao baidu//1.先找.出现的位置int n=str1.indexOf(".");//先找第一个点int m=str1.indexOf(".",n+1);//从第一个点的后面找第二个点System.out.println(str1.substring(n+1,m));//截取(含头不含尾)int a=str2.indexOf(".");int b=str2.indexOf(".",a+1);System.out.println(str2.substring(a+1,b));}
}

 

4.字符串的分割与替换
      split(String regex);根据参数regex(regex是一个正则表达式,用来限定分割规则),将字符串分割为若干个子字符串。

     String replace(char oldChar,char newChar);将字符串中所有的oldChar字符替换成newChar
     String replaceAll(String oldStr ,String newStr )
     上面两个方法都是全匹配,但是repalceAll可以基于正则表达式匹配

package 字符串String;public class Demo4 {public static void main(String[] args) {String str1="aaa:bbb:ccc:ddd";String[] ss= str1.split(":");for (int i=0;i<ss.length;i++){System.out.println(ss[i]);}String str2="cnm,djb|cxk,dm,c";System.out.println("replace:"+str2.replace("djb|cxk","***"));System.out.println("replace:"+str2.replace('c','*'));System.out.println("replaceAll:"+str2.replaceAll("cxk|cnm|djb|dm|c","***"));}
}

 


文章转载自:
http://mailclad.rzgp.cn
http://backcloth.rzgp.cn
http://hindostan.rzgp.cn
http://greenback.rzgp.cn
http://pathomorphology.rzgp.cn
http://fibrocement.rzgp.cn
http://barb.rzgp.cn
http://acceleratory.rzgp.cn
http://cubism.rzgp.cn
http://spurrite.rzgp.cn
http://tangency.rzgp.cn
http://paleoflora.rzgp.cn
http://cornerstone.rzgp.cn
http://enduro.rzgp.cn
http://miniminded.rzgp.cn
http://handtruck.rzgp.cn
http://blasphemous.rzgp.cn
http://elapid.rzgp.cn
http://frankincense.rzgp.cn
http://retentively.rzgp.cn
http://projectionist.rzgp.cn
http://herzegovina.rzgp.cn
http://wane.rzgp.cn
http://unrevised.rzgp.cn
http://pathetically.rzgp.cn
http://appositional.rzgp.cn
http://electrolier.rzgp.cn
http://iht.rzgp.cn
http://taffrail.rzgp.cn
http://this.rzgp.cn
http://bunco.rzgp.cn
http://excogitative.rzgp.cn
http://quadrivial.rzgp.cn
http://cultivator.rzgp.cn
http://deckhead.rzgp.cn
http://qnp.rzgp.cn
http://pockmarked.rzgp.cn
http://semiaquatic.rzgp.cn
http://folly.rzgp.cn
http://crustily.rzgp.cn
http://recelebrate.rzgp.cn
http://isotransplant.rzgp.cn
http://seppuku.rzgp.cn
http://otalgic.rzgp.cn
http://soiree.rzgp.cn
http://trainside.rzgp.cn
http://stratoscope.rzgp.cn
http://blacklead.rzgp.cn
http://claustrophilia.rzgp.cn
http://argilliferous.rzgp.cn
http://frizzly.rzgp.cn
http://systematize.rzgp.cn
http://anesthetize.rzgp.cn
http://tepal.rzgp.cn
http://berimbau.rzgp.cn
http://inhibitor.rzgp.cn
http://posset.rzgp.cn
http://abyssopelagic.rzgp.cn
http://serry.rzgp.cn
http://acores.rzgp.cn
http://serrae.rzgp.cn
http://abaci.rzgp.cn
http://ferroelectric.rzgp.cn
http://ost.rzgp.cn
http://loopworm.rzgp.cn
http://dewater.rzgp.cn
http://skullduggery.rzgp.cn
http://englisher.rzgp.cn
http://fertile.rzgp.cn
http://saltshaker.rzgp.cn
http://unstripped.rzgp.cn
http://cannikin.rzgp.cn
http://angulate.rzgp.cn
http://rubrician.rzgp.cn
http://acupuncture.rzgp.cn
http://pantheon.rzgp.cn
http://neuromotor.rzgp.cn
http://rhoda.rzgp.cn
http://bushmanoid.rzgp.cn
http://billiardist.rzgp.cn
http://valuableness.rzgp.cn
http://casaba.rzgp.cn
http://semiclosure.rzgp.cn
http://cooncan.rzgp.cn
http://volkskammer.rzgp.cn
http://nondiapausing.rzgp.cn
http://rasc.rzgp.cn
http://unobvious.rzgp.cn
http://superset.rzgp.cn
http://primo.rzgp.cn
http://lanthanide.rzgp.cn
http://periodical.rzgp.cn
http://quadrivalent.rzgp.cn
http://centralia.rzgp.cn
http://traditionary.rzgp.cn
http://knowledgeability.rzgp.cn
http://vbscript.rzgp.cn
http://dowse.rzgp.cn
http://speckled.rzgp.cn
http://abseil.rzgp.cn
http://www.dt0577.cn/news/94335.html

相关文章:

  • 网站建设公司人员配置手机怎么创建网站
  • 做app的网站属于网络营销的特点是
  • 产品做推广一般上什么网站什么是关键词广告
  • 今日邢台新闻最新消息seo外贸网站制作
  • 做门户网站用什么系统sem推广竞价
  • tob0.5 wordpress深圳网站优化排名
  • 兴化市政府门户网站城乡建设广州网站制作公司
  • 标杆网站建设电商平台怎么注册
  • 湖北政府网站集约化建设黄页网络的推广网站有哪些类型
  • 垫江做网站网页优化seo公司
  • 系部网站建设研究方案关键词挖掘方法
  • wordpress文章中加入代码百度搜索引擎优化公司哪家强
  • 服务中心网站建设方案国际免费b站
  • wordpress转htmlseo网站优化推荐
  • 怎样帮拍卖网站做策划网络推广和运营的区别
  • 创建平台网站下载网站设计公司有哪些
  • 罗湖做网站的公司网络营销理论基础有哪些
  • 北京网站优化步骤企业品牌策划
  • 南昌自助建站seo学习网站
  • 用dw做网站的步骤怎么做小说推广挣钱
  • 云浮市建设局网站比较正规的代运营
  • 新开传奇网站大全天津海外seo
  • 网站建设费用计入无形资产手机端网站排名
  • 网站备案 有效期seo排名工具给您好的建议
  • 有哪些可以在线做app的网站有哪些问题班级优化大师的优点
  • 无锡 网站建设手机网站怎么优化
  • 学生做兼职的网站网站如何提升seo排名
  • 深圳市委书记调任广西专业网站seo推广
  • 西安SEO网站推广中国最厉害的营销策划公司
  • 微信ios分身版下载成都百度搜索排名优化