最新苏教版语文七年级上册文言文与古诗文复习习题下载&amp#46;doc优秀名师资料.doc

上传人:小红帽 文档编号:1511531 上传时间:2018-12-20 格式:DOC 页数:41 大小:289KB
返回 下载 相关 举报
最新苏教版语文七年级上册文言文与古诗文复习习题下载&amp#46;doc优秀名师资料.doc_第1页
第1页 / 共41页
最新苏教版语文七年级上册文言文与古诗文复习习题下载&amp#46;doc优秀名师资料.doc_第2页
第2页 / 共41页
最新苏教版语文七年级上册文言文与古诗文复习习题下载&amp#46;doc优秀名师资料.doc_第3页
第3页 / 共41页
亲,该文档总共41页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《最新苏教版语文七年级上册文言文与古诗文复习习题下载&amp#46;doc优秀名师资料.doc》由会员分享,可在线阅读,更多相关《最新苏教版语文七年级上册文言文与古诗文复习习题下载&amp#46;doc优秀名师资料.doc(41页珍藏版)》请在三一文库上搜索。

1、苏教版语文七年级上册文言文与古诗文复习习题(免费下载).docChapter 9 Strings and Text I/O1Motivations2Objectives3The String Class4Constructing Strings5Strings Are Immutable6animationTrace CodeString s = Java;s = HTML;After executing s = HTML; After executing String s = Java; s : String This string object is : String s now unre

2、ferenced String object for Java String object for Java : String Contents cannot be changed String object for HTML 7animationTrace CodeString s = Java;s = HTML;After executing s = HTML; After executing String s = Java; s : String This string object is : String s now unreferenced String object for Jav

3、a String object for Java : String Contents cannot be changed String object for HTML 8Interned Strings9Exampless1 String s1 = Welcome to Java; : String s3 Interned string object for String s2 = new String(Welcome to Java); Welcome to Java String s3 = Welcome to Java; s2 : String System.out.println(s1

4、 = s2 is + (s1 = s2); System.out.println(s1 = s3 is + (s1 = s3); A string object for Welcome to Java 10animationTrace Codes1 String s1 = Welcome to Java; : String Interned string object for String s2 = new String(Welcome to Java); Welcome to Java String s3 = Welcome to Java; 11Trace Codes1 String s1

5、 = Welcome to Java; : String Interned string object for String s2 = new String(Welcome to Java); Welcome to Java String s3 = Welcome to Java; s2 : String A string object for Welcome to Java 12Trace Codes1 String s1 = Welcome to Java; : String s3 Interned string object for String s2 = new String(Welc

6、ome to Java); Welcome to Java String s3 = Welcome to Java; s2 : String A string object for Welcome to Java 13String Comparisonsjava.lang.String +equals(s1: String): boolean Returns true if this string is equal to string s1. +equalsIgnoreCase(s1: String): Returns true if this string is equal to strin

7、g s1 case-boolean insensitive. +compareTo(s1: String): int Returns an integer greater than 0, equal to 0, or less than 0 to indicate whether this string is greater than, equal to, or less than s1. +compareToIgnoreCase(s1: String): Same as compareTo except that the comparison is case-int insensitive.

8、 +regionMatches(toffset: int, s1: String, Returns true if the specified subregion of this string exactly offset: int, len: int): boolean matches the specified subregion in string s1. +regionMatches(ignoreCase: boolean, Same as the preceding method except that you can specify toffset: int, s1: String

9、, offset: int, whether the match is case-sensitive. len: int): boolean +startsWith(prefix: String): boolean Returns true if this string starts with the specified prefix. +endsWith(suffix: String): boolean Returns true if this string ends with the specified suffix. 14String Comparisons15String Compar

10、isons, cont.16String Length, Characters, and Combining Strings java.lang.String Returns the number of characters in this string. +length(): int Returns the character at the specified index from this string. +charAt(index: int): char Returns a new string that concatenate this string with string s1. +

11、concat(s1: String): String string. 17Finding String Length18Retrieving Individual Characters in a String0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Indices W e l c o m e t o J a v a message message.charAt(0) message.length() is 15 message.charAt(14) 19String Concatenation20Extracting Substringsjava.lang.Stri

12、ng Returns this strings substring that begins with the character at the +subString(beginIndex: int): specified beginIndex and extends to the end of the string, as String shown in Figure 8.6. +subString(beginIndex: int, Returns this strings substring that begins at the specified endIndex: int): Strin

13、g beginIndex and extends to the character at index endIndex 1, as shown in Figure 8.6. Note that the character at endIndex is not part of the substring. 21Extracting Substrings0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Indices W e l c o m e t o J a v a message message.substring(0, 11) message.substring(11)

14、22Converting, Replacing, and Splitting Strings java.lang.String +toLowerCase(): String Returns a new string with all characters converted to lowercase. +toUpperCase(): String Returns a new string with all characters converted to uppercase. +trim(): String Returns a new string with blank characters t

15、rimmed on both sides. +replace(oldChar: char, Returns a new string that replaces all matching character in this newChar: char): String string with the new character. +replaceFirst(oldString: String, Returns a new string that replaces the first matching substring in newString: String): String this st

16、ring with the new substring. +replaceAll(oldString: String, Returns a new string that replace all matching substrings in this newString: String): String string with the new substring. +split(delimiter: String): Returns an array of strings consisting of the substrings split by the String delimiter. 2

17、3Examples24Splitting a StringString tokens = Java#HTML#Perl.split(#, 0);for (int i = 0; i tokens.length; i+) System.out.print(tokensi + );25Matching, Replacing and Splitting by Patterns 26Matching, Replacing and Splitting by Patterns 27Matching, Replacing and Splitting by Patterns 28Finding a Charac

18、ter or a Substring in a Stringjava.lang.String Returns the index of the first occurrence of ch in the string. +indexOf(ch: char): int Returns -1 if not matched. +indexOf(ch: char, fromIndex: Returns the index of the first occurrence of ch after fromIndex in int): int the string. Returns -1 if not ma

19、tched. +indexOf(s: String): int Returns the index of the first occurrence of string s in this string. Returns -1 if not matched. +indexOf(s: String, fromIndex: Returns the index of the first occurrence of string s in this string int): int after fromIndex. Returns -1 if not matched. +lastIndexOf(ch:

20、int): int Returns the index of the last occurrence of ch in the string. Returns -1 if not matched. +lastIndexOf(ch: int, Returns the index of the last occurrence of ch before fromIndex fromIndex: int): int in this string. Returns -1 if not matched. +lastIndexOf(s: String): int Returns the index of t

21、he last occurrence of string s. Returns -1 if not matched. +lastIndexOf(s: String, Returns the index of the last occurrence of string s before fromIndex: int): int fromIndex. Returns -1 if not matched. 29Finding a Character or a Substring in a String30Convert Character and Numbers to Strings31Proble

22、m: Finding PalindromesCheckPalindromeCheckPalindromeRun32The Character Classjava.lang.Character +Character(value: char) Constructs a character object with char value +charValue(): char Returns the char value from this object +compareTo(anotherCharacter: Character): int Compares this character with a

23、nother +equals(anotherCharacter: Character): boolean Returns true if this character equals to another +isDigit(ch: char): boolean Returns true if the specified character is a digit +isLetter(ch: char): boolean Returns true if the specified character is a letter +isLetterOrDigit(ch: char): boolean Re

24、turns true if the character is a letter or a digit +isLowerCase(ch: char): boolean Returns true if the character is a lowercase letter +isUpperCase(ch: char): boolean Returns true if the character is an uppercase letter +toLowerCase(ch: char): char Returns the lowercase of the specified character +t

25、oUpperCase(ch: char): char Returns the uppercase of the specified character 33Examples34Problem: Counting Each Letter in a StringCountEachLetterCountEachLetterRun35StringBuilder and StringBuffer36StringBuilder Constructorsjava.lang.StringBuilder +StringBuilder() Constructs an empty string builder wi

26、th capacity 16. +StringBuilder(capacity: int) Constructs a string builder with the specified capacity. +StringBuilder(s: String) Constructs a string builder with the specified string. 37Modifying Strings in the Builderjava.lang.StringBuilder Appends a char array into this string builder. +append(dat

27、a: char): StringBuilder Appends a subarray in data into this string builder. +append(data: char, offset: int, len: int): StringBuilder Appends a primitive type value as a string to this +append(v: aPrimitiveType): StringBuilder builder. Appends a string to this string builder. +append(s: String): St

28、ringBuilder Deletes characters from startIndex to endIndex. +delete(startIndex: int, endIndex: int): StringBuilder Deletes a character at the specified index. +deleteCharAt(index: int): StringBuilder Inserts a subarray of the data in the array to the builder +insert(index: int, data: char, offset: i

29、nt, at the specified index. len: int): StringBuilder Inserts data into this builder at the position offset. +insert(offset: int, data: char): StringBuilder +insert(offset: int, b: aPrimitiveType): Inserts a value converted to a string into this builder. StringBuilder +insert(offset: int, s: String):

30、 StringBuilder Inserts a string into this builder at the position offset. +replace(startIndex: int, endIndex: int, s: Replaces the characters in this builder from startIndex String): StringBuilder to endIndex with the specified string. +reverse(): StringBuilder Reverses the characters in the builder

31、. +setCharAt(index: int, ch: char): void Sets a new character at the specified index in this builder. 38Examples39The toString, capacity, length, setLength, and charAt Methods java.lang.StringBuilder +toString(): String Returns a string object from the string builder. +capacity(): int Returns the ca

32、pacity of this string builder. +charAt(index: int): char Returns the character at the specified index. +length(): int Returns the number of characters in this builder. +setLength(newLength: int): void Sets a new length in this builder. +substring(startIndex: int): String Returns a substring starting

33、 at startIndex. +substring(startIndex: int, endIndex: int): Returns a substring from startIndex to endIndex-1. String +trimToSize(): void Reduces the storage size used for the string builder. 40Problem: Checking Palindromes Ignoring Non-alphanumeric CharactersPalindromeIgnoreNonAlphanumeric Palindro

34、meIgnoreNonAlphanumeric Run41Main Method Is Just a Regular Methodpublic class A class B public static void main(String args) public static void main(String args) String strings = New York, for (int i = 0; i args.length; i+) Boston, Atlanta; System.out.println(argsi); B.main(strings); 42Command-Line

35、Parameters43ProcessingCommand-Line Parameters44Problem: CalculatorCalculatorCalculatorRun45Regular Expressions46Matching Strings47Regular Expression SyntaxRegular Expression Matches Example x a specified character x Java matches Java . any single character Java matches J.a (ab|cd) a, b, or c ten mat

36、ches t(en|im abc a, b, or c Java matches Jauvwxa abc any character except Java matches Jaarsa a, b, or c a-z a through z Java matches A-Mava-d a-z any character except Java matches Javb-d a through z a-em-p a through e or Java matches m through p A-GI-Mava-d a-e&c-p intersection of a-e Java matches

37、with c-p A-P&I-Mava-d d a digit, same as 1-9 Java2 matches Javad D a non-digit $Java matches DDava w a word character Java matches wava W a non-word character $Java matches Wwava s a whitespace character Java 2 matches Javas2 S a non-whitespace char Java matches Sava p* zero or more Java matches w*

38、occurrences of pattern p p+ one or more Java matches w+ occurrences of pattern p p? zero or one Java matches w?Java occurrence of pattern p Java matches w?ava pn exactly n Java matches w4 occurrences of pattern p pn, at least n Java matches w3, occurrences of pattern p pn,m between n and m Java matc

39、hes w1,9 occurrences (inclusive) 48Replacing and Splitting Stringsjava.lang.String +matches(regex: String): boolean Returns true if this string matches the pattern. +replaceAll(regex: String, Returns a new string that replaces all replacement: String): String matching substrings with the replacement

40、. +replaceFirst(regex: String, Returns a new string that replaces the first replacement: String): String matching substring with the replacement. +split(regex: String): String Returns an array of strings consisting of the substrings split by the matches. 49Examples50The File Class51java.io.File Obta

41、ining file Creates a File object for the specified pathname. The pathname may be a +File(pathname: String) properties and directory or a file. +File(parent: String, child: String) Creates a File object for the child under the directory parent. child may be a manipulating filename or a subdirectory.

42、+File(parent: File, child: String) Creates a File object for the child under the directory parent. parent is a File fileobject. In the preceding constructor, the parent is a string. +exists(): boolean Returns true if the file or the directory represented by the File object exists. +canRead(): boolea

43、n Returns true if the file represented by the File object exists and can be read. +canWrite(): boolean Returns true if the file represented by the File object exists and can be written. +isDirectory(): boolean Returns true if the File object represents a directory. +isFile(): boolean Returns true if

44、 the File object represents a file. +isAbsolute(): boolean Returns true if the File object is created using an absolute path name. +isHidden(): boolean Returns true if the file represented in the File object is hidden. The exact definition of hidden is system-dependent. On Windows, you can mark a fi

45、le hidden in the File Properties dialog box. On Unix systems, a file is hidden if its name begins with a period character . +getAbsolutePath(): String Returns the complete absolute file or directory name represented by the File object. +getCanonicalPath(): String Returns the same as getAbsolutePath(

46、) except that it removes redundant names, such as . and ., from the pathname, resolves symbolic links (on Unix platforms), and converts drive letters to standard uppercase (on Win32 platforms). +getName(): String Returns the last name of the complete directory and file name represented by the File object. For example, new File(c:booktest.dat).getName() returns test.dat. +getPath(): String Returns the complete directory and file name represented by the File object. For example, new File(c:booktest.dat).getP

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1