Sei sulla pagina 1di 3

SOFTWARE DEVELOPMENT V

PART B
TABLE OF CONTENTS
Chapter 5: Strings and Characters
Objectives.........................................................................................................................5-1
5.1: The String Class..........................................................................................5-2
5.1.1: The String Class Documentation..............................................................5-2
5.1.2: The String Practice Examples................................................................5-26
5.1.2.1: Processing_Strings.java..................................................................5-26
5.1.2.2: String_Value_Of.java.....................................................................5-28
5.1.2.3: StringsMisc.java.............................................................................5-29
5.1.2.4: UserInputStringsCompare.java......................................................5-31
5.1.2.5: PlayingCards.java...........................................................................5-33
5.1.3: The String Practice Exercise.................................................................5-36
5.1.3.1: SorttheStrings.java..........................................................................5-36
5.1.3.2: PokerDemo.java.............................................................................5-36
5.1.4: Solutions to The String Practice Exercises............................................5-37
5.1.4.1: SorthteStrings.java..........................................................................5-37
5.1.4.2: PokerDemo.java.............................................................................5-38
5.2: Java Characters.........................................................................................5-42
5.2.1: Character Class......................................................................................5-42
5.2.2: Character Class: Practice Example........................................................5-64
5.2.2.1: StaticCharacterMethods.java..........................................................5-64
5.2.2.2: Chars_and_Ints.java.......................................................................5-66
5.2.2.3: Strings_and _Chars.java.................................................................5-67
5.3: StringBuffer Class.....................................................................................5-69
5.3.1: StringBuffer Complete Reference.........................................................5-69
5.3.2: A StringBuffer Practice Example..........................................................5-85
5.3.2.1: StringBufferDemo.java..................................................................5-85
5.4: StringTokenizer Class...............................................................................5-89
5.4.1: StringTokenizer Complete Reference...................................................5-90
5.4.2: StringTokenizer Practice Example........................................................5-93
5.4.2.1: StringTokenizerDemo.java.............................................................5-93
Chapter 6: Exception Handling in Java
Objectives.........................................................................................................................6-1
6.1: Exception Handling in Java.......................................................................6-2
6.2: Exception Handling Practice Examples....................................................6-4
6.2.1: ExceptionsExample.java.........................................................................6-4
6.2.2: NestedExceptionHandling.java...............................................................6-8
6.2.3: PrintStackTraceExample.java.................................................................6-9

Chapter 7: Files and Streams in Java


Objectives.........................................................................................................................7-1
7.1: Files and Streams in Java..........................................................................7-2
7.2: Files and Streams in Java: Practice Examples......................................7-50
7.2.1: Create_Bin_Seq_File.java.....................................................................7-50
7.2.2: Course.java............................................................................................7-52
7.3: Files and Streams in Java: Practice Exercises.......................................7-58
7.3.1: Read_Bin_Seq_File.java.......................................................................7-58
7.3.2: Analyze_Bin_Seq_File.java..................................................................7-58
7.4: Files and Streams in Java: Solutions to Practice Exercises..................7-59
7.4.1: Read_Bin_Seq_File.java.......................................................................7-59
7.4.2: Analyze_Bin_Seq_File.java..................................................................7-61
Chapter 8: Multithreading in Java
Objectives.........................................................................................................................8-1
8.1: Introduction................................................................................................8-2
8.2: Class Thread and Interface Runnable: An Overview.............................8-4
8.3: Thread Synchronization..........................................................................8-18
8.4: Practice Examples....................................................................................8-19
8.4.1: PrintTestApplication.java.....................................................................8-19
8.4.2: Modifying_a_Shared_Object.java.........................................................8-21
8.4.3: Modifying_a_Shared_Object_with_Synchronization.java...................8-23
8.4.4: Runnable_Interface_Example.java........................................................8-27
8.4.5: High_Priority_Thread _Example_1.java...............................................8-30
8.5: Practice Exercises.....................................................................................8-32
8.5.1: PrintTestApplet.java..............................................................................8-32
8.5.2: Modifying_a_Shared_Object_with_Synchronization_
using_Buffer.java..................................................................................8-33
8.5.3: High_Priority_Thread _Example_2.java...............................................8-34
8.6: Solutions to Practice Exercises................................................................8-35
8.6.1: PrintTestApplet.java..............................................................................8-35
8.6.2: Modifying_a_Shared_Object_with_Synchronization_
using_Buffer.java..................................................................................8-37
8.6.3: High_Priority_Thread _Example_2.java...............................................8-40
Appendix 'A': Networking Programming using Stream Sockets in Java
Objectives........................................................................................................................A-1
A.1: Introduction..............................................................................................A-2
A.2: Class InetAddress, URL, ServerSocket and Socket: An Overview.....A-2
A.2.1: Class java.net.InetAddress....................................................................A-2
A.2.2: Class java.net.URL...............................................................................A-5

A.2.3: Class java.net.ServerSocket.................................................................A-10


A.2.4: Class java.net.Socket...........................................................................A-12
A.2.5: Class java.net.MalformedURLException............................................A-16
A.3: Practice Examples..................................................................................A-17
A.3.1: Bookmarked_Sites.java.......................................................................A-17
A.3.2: Read_a_Remote_File.java...................................................................A-19
A.3.3: Client / Server Programming using Stream Sockets............................A-21
A.3.3.1: Local_Client.java..........................................................................A-22
A.3.3.2: Local_Client2.java........................................................................A-26
A.3.3.3: Local_Client3.java........................................................................A-29
A.3.3.4: Local_Client4.java........................................................................A-34
Appendix 'B': Java 2 Enhancements to Java 1
Objectives........................................................................................................................B-1
B.1: JavaTM 2 Platform, Standard Edition, v1.2.2 API Specification........B-2
B.2: Package javax.swing.................................................................................B-6
B.3: Why Are Thread.stop, Thread.suspend, Thread.resume and
Runtime.runFinalizersOnExit Deprecated in JDK 1.2?.....................B-19
.................................................................................................................................