Couple of Days back i started reading Beginning Java 2, JDK 5 Edition By Ivor Horton.
Nice book written by Ivor Horton.
Below are few quotations i found from this book from the remaining chapters.
1) The java.util.Arrays class provides static methods for sorting, searching, filling, and comparing arrays.
2) Objects of type Random can generate pseudo-random numbers of type int, long, float, and double. The integers are uniformly distributed across the range of the type int or long. The floating-point numbers are between 0.0 and 1.0. You can also generate numbers of type double with a Gaussian distribution with a mean of 0.0 and a standard deviation of 1.0 and random boolean values.
3) Classes derived from the Observable class can signal changes to classes that implement the Observer interface. You define the Observer objects that are to be associated with an Observable class object by calling the addObserver() method. This is primarily intended to be used to implement the document/view architecture for applications in a GUI environment.
4) You can create Date objects to represent a date and time that you specify in milliseconds since January 1, 1970, 00:00:00 GMT or as the current date and time from your computer clock.
5) You can use a DateFormat object to format the date and time for a Date object as a string. The format will be determined by the style and the locale that you specify.
6) A GregorianCalendar object represents a calendar set to an instant in time on a given date.
7) A regular expression defines a pattern that is used for searching text.
8) In Java, a regular expression is compiled into a Pattern object that you can then use to obtain a Matcher object that will scan a given string looking for the pattern.
9) The appendReplacement() method for a Matcher object enables you to make substitutions for patterns found in the input text.
10) A capturing group in a regular expression records the text that matches a subpattern.
11) By using capturing groups you can rearrange the sequence of substrings in a string matching a pattern.
12) A Scanner object uses a regular expression to segment data from a variety of sources into tokens.
13) A daemon thread is simply a background thread that is subordinate to the thread that creates it, so when the thread that created the daemon thread ends, the daemon thread dies with it.
14) Connecting Threads
If in one thread you need to wait until another thread dies, you can call the join() method for the thread that you expect isn’t long for this world. Calling the join() method with no arguments will halt the current thread for as long as it takes the specified thread to die:
thread1.join(); // Suspend the current thread until thread1 dies
You can also pass a long value to the join() method to specify the number of milliseconds you’re prepared
to wait for the death of a thread:
thread1.join(1000); // Wait up to 1 second for thread1 to die
If this is not precise enough, you have a version of join() with two parameters. The first is a time in
milliseconds and the second is a time in nanoseconds. The current thread will wait for the duration specified
by the sum of the arguments. Of course, whether or not you get nanosecond resolution will depend on the capability of your hardware.
The join() method can throw an InterruptedException if the current thread is interrupted by another thread, so you should put a call to join() in a try block and catch the exception.
15) Threads are subtasks in a program that can be in execution concurrently.
16) A thread is represented by an object of the class Thread. Execution of a thread begins with the execution of the run() method defined in the class Thread.
17) You define the code to be executed in a thread by implementing the run() method in a class derived from Thread, or in a class that implements the interface Runnable.
18) A thread specified as daemon will cease execution when the thread that created it ends.
19) A thread that isn’t a daemon thread is called a user thread. A user thread will not be terminated automatically when the thread that created it ends.
20) You start execution of a thread by calling the start() method for its Thread object. If you need to halt a thread before normal completion, you can stop execution of a thread by calling the interrupt() method for its Thread object.
21) Methods can be declared as synchronized. Only one synchronized instance method for an object can execute at any given time. Only one synchronized static method for a class can execute at one time.
22) A code block can be declared as synchronized on an object. Only one synchronized code block for an object can execute at any given time.
23)In a synchronized method or code block, you can call the wait() method inherited from the class Object to halt execution of a thread. Execution of the waiting thread will continue when the notify() or notifyAll() method inherited from Object is called by a thread synchronized on the same object.
24) The notify() or notifyAll() method can be called only from a method or code block that is synchronized to the same object as the method or block that contains the wait() method that halted the thread.
25) A deadlock is a situation in which two threads are both waiting for the other to complete some action. Deadlocks can occur in subtle ways in multi-threaded applications, which makes such applications difficult to debug.
26) You can modify the relative priority of a thread by calling its setPriority() method. This has an effect on execution only in environments that support priority scheduling.
27) XML is a language for describing data that is to be communicated from one computer to another. Data is described in the form of text that contains the data plus markup that defines the structure of the data.
28) XML is also a meta-language because you can use XML to create new languages for defining and structuring data.
29) Markup consists of XML elements that may also include attributes, where an attribute is a name-value pair.
30) The structure and meaning of a particular type of document can be defined within a Document Type Definition (DTD).
31) A DTD can be defined in an external file or it can be part of a document.
32) A DTD is identified by a DOCTYPE declaration in a document.
33)The Schema Definition language provides a more flexible alternative to DTDs.
34)An XML namespace defines a set of names qualified by a prefix that corresponds to a URI.
35)The SAX API defines a simple event-driven mechanism for analyzing XML documents.
36) A SAX parser is a program that parses an XML document and identifies each element in a document by calling a particular method in your program. The methods that are called are those defined by the SAX API.
About the Author
Ivor Horton started out as a mathematician, but shortly after graduating, he was lured into messing about with computers by a well-known manufacturer. He has spent many happy years programming occasionally useful applications in a variety of languages as well as teaching mainly scientists and engineers to do likewise. He has extensive experience in applying computers to problems in engineering design and to manufacturing operations in a wide range of industries. He is the author of a number of tutorial books on programming in C, C++, and Java. When not writing programming books or providing advice to others, he leads a life of leisure.
Wednesday, 8 October 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment