ImageVerifierCode 换一换
格式:PPT , 页数:43 ,大小:297KB ,
文档编号:7175740      下载积分:22 文币
快捷下载
登录下载
邮箱/手机:
温馨提示:
系统将以此处填写的邮箱或者手机号生成账号和密码,方便再次下载。 如填写123,账号和密码都是123。
支付方式: 支付宝    微信支付   
验证码:   换一换

优惠套餐
 

温馨提示:若手机下载失败,请复制以下地址【https://www.163wenku.com/d-7175740.html】到电脑浏览器->登陆(账号密码均为手机号或邮箱;不要扫码登陆)->重新下载(不再收费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  
下载须知

1: 试题类文档的标题没说有答案,则无答案;主观题也可能无答案。PPT的音视频可能无法播放。 请谨慎下单,一旦售出,概不退换。
2: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
3: 本文为用户(ziliao2023)主动上传,所有收益归该用户。163文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(点击联系客服),我们立即给予删除!。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

1,本文(Java课件第二章补充-字符串.ppt)为本站会员(ziliao2023)主动上传,163文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。
2,用户下载本文档,所消耗的文币(积分)将全额增加到上传者的账号。
3, 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(发送邮件至3464097650@qq.com或直接QQ联系客服),我们立即给予删除!

Java课件第二章补充-字符串.ppt

1、2021/7/1312021/7/132The The StringString Class Class2021/7/133Constructing StringsConstructing Strings2021/7/134String pool(字符串池字符串池):JVM has a String pool,it saves a lot of String objects that created by shorthand initializer.Data sharingStack(栈)(栈):Store primitive data(char、byte、short、int、long、flo

2、at、double、boolean)and constructor.Data sharing.heap(堆)(堆):Store Object.2021/7/135Difference between new and shorthand initializerDifference between new and shorthand initializerQuestion:How many String objects are created?TwoConstructor:public String(String original)/other code.vNote:The parameter i

3、s a String object2021/7/136Difference between new and shorthand initializerDifference between new and shorthand initializerQuestion:How many String objects are created?One2021/7/1372021/7/138Strings Are ImmutableStrings Are Immutable2021/7/139Trace CodeTrace CodeAfter executing s=“java”;After execut

4、ing s=“HTML”;2021/7/1310Canonical StringsCanonical Strings(规范字符串)(规范字符串)improve efficiency and save memoryvUsing String objects intern method to return a canonical string2021/7/1311 intern:public native String intern()Returns a canonical representation for the string object.If s and t are strings su

5、ch that s.equals(t),it is guaranteed that s.intern()=t.intern().Canonical StringsCanonical Strings2021/7/1312ExamplesExamples2021/7/1313Finding String LengthFinding String Length2021/7/1314Retrieving Individual Characters in a StringRetrieving Individual Characters in a String W e l c o m e t o J a

6、v a 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 message Indices message.charAt(0)message.charAt(14)message.length()is 15 2021/7/1315String Concatenation2021/7/1316String ConcatenationString Concatenation2021/7/1317Extracting Substrings2021/7/1318Extracting SubstringsExtracting Substrings W e l c o m e t o J

7、a v a 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 message Indices message.substring(0,11)message.substring(11)2021/7/1319String ComparisonsString Comparisons2021/7/1320String Comparisons,cont.String Comparisons,cont.2021/7/1321String ConversionsString Conversionsv 2021/7/1322Finding a Character or a Substrin

8、g in a StringFinding a Character or a Substring in a String2021/7/1323Convert Character and Numbers to StringsConvert Character and Numbers to Strings2021/7/1324The Character ClassThe Character Class Character +Character(value:char)+charValue():char+compareTo(anotherCharacter:Character):int+equals(a

9、notherCharacter:Character):boolean+isDigit(ch:char):boolean +isLetter(ch:char):boolean +isLetterOrDigit(ch:char):boolean +isLowerCase(ch:char):boolean +isUpperCase(ch:char):boolean +toLowerCase(ch:char):char +toUpperCase(ch:char):char Constructs a character object with char value Returns the char va

10、lue from this object Compares this character with another Returns true if this character equals to another Returns true if the specified character is a digit Returns true if the specified character is a letter Returns true if the character is a letter or a digit Returns true if the character is a lo

11、wercase letter Returns true if the character is an uppercase letter Returns the lowercase of the specified character Returns the uppercase of the specified character 2021/7/1325ExamplesExamples2021/7/1326The StringBuffer ClassThe StringBuffer Class2021/7/1327 StringBuffer +StringBuffer()+StringBuffe

12、r(capacity:int)+StringBuffer(str:String)+append(data:char):StringBuffer+append(data:char,offset:int,len:int):StringBuffer+append(v:aPrimitiveType):StringBuffer+append(str:String):StringBuffer+capacity():int+charAt(index:int):char+delete(startIndex:int,endIndex:int):StringBuffer+deleteCharAt(int inde

13、x):StringBuffer+insert(index:int,data:char,offset:int,len:int):StringBuffer+insert(offset:int,data:char):StringBuffer+insert(offset:int,b:aPrimitiveType):StringBuffer+insert(offset:int,str:String):StringBuffer+length():int+replace(int startIndex,int endIndex,String str):StringBuffer+reverse():String

14、Buffer+setCharAt(index:int,ch:char):void+setLength(newLength:int):void+substring(startIndex:int):String+substring(startIndex:int,endIndex:int):String Constructs an empty string buffer with capacity 16 Constructs a string buffer with the specified capacity Constructs a string buffer with the specifie

15、d string Appends a char array into this string buffer Appends a subarray in data into this string buffer Appends a primitive type value as string to this buffer Appends a string to this string buffer Returns the capacity of this string buffer Returns the character at the specified index Deletes char

16、acters from startIndex to endIndex Deletes a character at the specified index Inserts a subarray of the data in the array to the buffer at the specified index Inserts data to this buffer at the position offset Inserts a value converted to string into this buffer Inserts a string into this buffer at

17、the position offset Returns the number of characters in this buffer Replaces the characters in this buffer from startIndex to endIndex with the specified string Reveres the characters in the buffer Sets a new character at the specified index in this buffer Sets a new length in this buffer Returns a

18、substring starting at startIndex Returns a substring from startIndex to endIndex 2021/7/1328StringBuffer ConstructorsStringBuffer Constructors2021/7/1329Appending New Contents into a String BufferAppending New Contents into a String Buffer2021/7/13302021/7/13312021/7/1332The StringTokenizer ClassThe

19、 StringTokenizer Class java.util.StringTokenizer +StringTokenizer(s:String)+StringTokenizer(s:String,delimiters:String)+StringTokenizer(s:String,delimiters:String,returnDelimiters:boolean)+countTokens():int+hasMoreTokens():boolean+nextToken():String +nextToken(delimiters:String):String Constructs a

20、string tokenizer for the string.Constructs a string tokenizer for the string with the specified delimiters.Constructs a string tokenizer for the string with the delimiters and returnDelims.Returns the number of remaining tokens.Returns true if there are more tokens left.Returns the next token.Return

21、s the next token using new delimiters.2021/7/1333Examples 1Examples 1String s=Java is cool.;StringTokenizer tokenizer=new StringTokenizer(s);System.out.println(The total number of tokens is +tokenizer.countTokens();while(tokenizer.hasMoreTokens()System.out.println(tokenizer.nextToken();.2021/7/1334E

22、xamples 2Examples 2String s=Java is cool.;StringTokenizer tokenizer=new StringTokenizer(s,ac);System.out.println(The total number of tokens is +tokenizer.countTokens();while(tokenizer.hasMoreTokens()System.out.println(tokenizer.nextToken();2021/7/1335Examples 3Examples 3String s=Java is cool.;String

23、Tokenizer tokenizer=new StringTokenizer(s,ac,true);System.out.println(The total number of tokens is +tokenizer.countTokens();while(tokenizer.hasMoreTokens()System.out.println(tokenizer.nextToken();2021/7/1336No no-arg Constructor in StringTokenizerNo no-arg Constructor in StringTokenizer2021/7/1337T

24、he Scanner ClassThe Scanner ClassString s=Welcome to Java!Java is fun!Java is cool!;Scanner scanner=new Scanner(s);scanner.useDelimiter(Java);while(scanner.hasNext()System.out.println(scanner.next();Welcome to!is fun!is cool!2021/7/1338Scanning Primitive Type ValuesScanning Primitive Type ValuesStri

25、ng s=1 2 3 4;Scanner scanner=new Scanner(s);int sum=0;while(scanner.hasNext()sum+=scanner.nextInt();System.out.println(Sum is +sum);2021/7/1339Console Input Using ScannerConsole Input Using ScannerSystem.out.print(Please enter an int value:);Scanner scanner=new Scanner(System.in);int i=scanner.nextInt();2021/7/1340Command-Line ParametersCommand-Line Parameters2021/7/1341Processing Command-Line ParametersProcessing Command-Line Parameters2021/7/1342问题?问题?

侵权处理QQ:3464097650--上传资料QQ:3464097650

【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。


163文库-Www.163Wenku.Com |网站地图|