Đang chuẩn bị liên kết để tải về tài liệu:
Lecture Java programming language: Loop Structures and Strings - Ho Dac Hung
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Loop Structures and Strings has main content such as the while statement, the do-while statemen, infinite loops , the for statement, debugging techniques, the string class, the string class, comparing strings. | Loop Structures and Strings Ho Dac Hung 1 The while Statement The while statement is a loop structure which executes a set of statements over and over again based on a condition. The while statement takes the form while 2 The do-while Statement The do-while statement is an alternative form of the while statement. In the do-while statement the condition is not evaluated until after the first execution of the loop. The do-while takes the following form do while 3 Infinite Loops The condition of a loop is used to determine when the loop should stop executing. A while continues until its conditon is false. What happens though if the condition never becomes false The result is an infinite loop one which continues forever. 4 The for Statement The for statement is a loop structure that executes a set of statements a fixed number of times. The for statement takes the form for 5 Debugging Techniques The source of bugs which are often logic errors can be hard to determine withoud tools for debugging an application. Debugging is the process of getting an application work correctly. A debugger is used to select statements where execution will be suspsned. These statements are called breakpoints. 6 The String class Java includes the String class in the java.lang package for storing and manipulating strings. The String class is large with numerous methods for string manipulation. 7 The String class charAt int index length isEmpty substring int start int end substring int start toLowerCase toUpperCase trim replace String str1 String str2 8 Comparing Strings Strings are compared when determining equality or alphabetical order. Relational operators are used to compare primitive types. When objects need to be comparedm methods from their class are used. Some of the String class methods are used to compare strings. 9 Comparing Strings equals String str equalsIgnoreCase String str compareTo String str compareToIgnoreCase String str indexOf String str startWith String str endWith .