C

compared with Java, 2 cache clearCache methods, 403 SoftReference objects, 261-262 Calendar class, 417-420 clear method, 418

displayWeekdayNames method, 420 factory methods, 417 get methods, 418 getDisplayName method, 418 getDisplayNames method, 418, 420 getTime method, 420 set methods, 418 setTime method, 420 calendars

GregorianCalendar class, 417 internationalization, 415 JapaneselmperialCalendar class, 417 outputting calendar pages, 418 Thai Buddhist calendar, 417 call method, Callable interface, 385 calculating Euler's number, 389 Callable instance

Executors class returning, 387 Callable interface, 382

call method, 385 callable tasks, 382, 385 invokeAll method, 383 submit method, 384

submitting callable task to executor, 386 callbacks, 116 camel-casing, 44

cancel method, Future interface, 385 CancellationException, 385 candidate bundle names, 401, 402 canEncode method, Charset, 517 canExecute method, File, 456 canonical pathname getCanonicalFile method, 452 getCanonicalPath method, 452 obtaining abstract pathname information, 453 canRead method, File, 454 canWrite method, File, 454 capacity array, 283 ArrayList class, 329 ensureCapacity method, 283 hashtable, 358

capacity method, StringBuffer, 283 capturing groups, 440-441

back reference, 441 Car class, inheritance, 98, 99 Card enum, Four of a Kind game, 25 Card object, Four of a Kind game, 26, 28 leastDesirableCard method, 34 rank method, 26 suit method, 26 caret detecting logical boundaries within text, 409 carriage return escape sequence for, 49 line terminator, 439 case reserved word equalslgnoreCase method, 279 switch statement, 65 toLowerCase method, 280 toUpperCase method, 280 case statement, 65 cast operator, 52

conversions, 56 casting byte cast, 56 downcasting, 121-123 upcasting, 117-119 catch clause coding empty catch clauses, 171 final rethrow, 172

handling exceptions, 168, 169, 170 multicatch, 171 naming conventions, 169 wrapping exceptions, 171 catch reserved word, 168 cause (wrapped exception), 164 ceil method, Math, 228 CEILING constant, RoundingMode enum, 238

chained instance method calls, 92 Character class, 142, 250-251

Unicode-related complexity, 250 character classes, 439-440 character encodings, 511-512 accessing default, 514 Charset class finding, 516 dumping to standard output, 516 character literal, 49 character sets, 511-512 Character type, 46

getChar method, 275

toCharArray method, 280 characters, 511

getCharacterlnstance method, 409, 410 readChar method, 464 setCharAt method, 283 using character-based break iterator, 411

writeChars method, 465 charAt method

CharSequence interface, 436 String class, 278, 281 StringBuffer class, 283 CharSequence interface, 436 Charset class, 516-517

java.nio.charset package, 514, 515 CharsetDecoder class, 515 CharsetEncoder class, 514 charsets, 517

auto-detect charset, 517 charValue method, Character, 250 checked exceptions, 164, 168 checkError method, PrintStream, 511 child class see subclasses child thread, 310

childValue method, InheritableThreadLocal, 310

class attributes, fields, 45 Class class, 270-274

forName method, 270, 272, 273, 277 getAnnotations method, 270, 274 getDeclaredAnnotations method, 270, 274

methods, 270-272 obtaining Class object, 277 processing annotations, 199 class extension see implementation inheritance class field initialization, 48, 75, 82 class fields, 48, 94 accessing, 88 read-only class fields, 57 class header declaration strictfp used in, 234 class initialization, 77, 82 class invariants class literals, 277 class methods, 60 calling methods, 89 main method, 60 class reserved word, 44 CLASS retention policy, 196, 197

ClassCastException, 108, 122, 317, 321

generics, 200, 201, 202, 205, 209, 211 classes, 43-85 see also objects abstract classes, 120-121, 133 access control levels, 82 anonymous classes, 146-148 camel-casing of name, 44 character classes, 439-440 compatible class change, 500 composition, 112 constructors, 75-76 declaring, 44-45 declaring fields, 45-48 declaring methods, 58-60 declaring variables, 45 description, 94 extending, 98-102 fields, 45-58

final reserved word, 98, 101 generics, 200-214 generified classes, 200 getClass method, 103, 277 getDeclaringClass method, 274 getSuperclass method, 272 identifiers, 44 immutable classes, 100 implementation, 82 implementing interfaces, 127-129 implementing methods, 60-74 incompatible changes, 500 information hiding, 82 inheritance, 97-116 initialization order, 78-82, 102 initializing fields, 48-57 initializing instance fields, 75 inner classes, 139 interfaces, 82, 125-136 interfaces within, 150 intersection character classes, 440 local classes, 148-150 method overloading, 74 methods, 58-75 multiple inheritance, 102 naming convention for, 44 negation character classes, 439 nested classes, 139-150 nonstatic member classes, 142-145 packages, 151

predefined character classes, 440 primitive wrapper classes, 247-257

range character classes, 439 read-only fields, 57-58 static member classes, 139-142 stream classes, 473-475 subtraction character classes, 440 top-level classes, 139 types, 44

union character classes, 439 utility classes, 234 wrapper classes, 115, 116 classes, list of see also exception classes AbstractExecutorService, 386 AccessibleObject, 276 Array, 276

ArrayBlockingQueue, 392 ArrayList, 329-330 Arrays, 369-371, 434 BigDecimal, 234-239 Biglnteger, 239-243 BitSet, 373-376 BitStreamlnputStream, 492 BitStreamOutputStream, 492 Boolean, 248-250 Breaklterator, 409 BrokenBarrierException, 390 BufferedlnputStream, 492, 493 BufferedOutputStream, 492 BufferedReader, 522 Byte, 255-257

ByteArraylnputStream, 477, 478

ByteArrayOutputStream, 477, 478-479

Character, 142, 250-251

Class, 270-274

ClassLoader, 402

Collator, 413

Collections, 371-372, 434 ConcurrentHashMap, 392 ConcurrentLinkedQueue, 392 Constructor, 274-275 CountDownLatch, 390 CyclicBarrier, 390 DatalnputStream, 494 DataOutputStream, 494 DateFormat, 424 DateFormatSymbols, 425 DecimalFormat, 424 DecimalFormatSymbols, 424 Dictionary, 372 Double, 251-254 DumpArgs, 8

EchoText, 10 Enum, 220-222 EnumMap, 366 EnumSet, 337-339 Error, 164 EventQueue, 407 Exception, 164 Exchanger, 390 Executors, 387 Field, 275 File, 449-462 FileDescriptor, 466 FilelnputStream, 479-481 FileOutputStream, 479 FileReader, 520-522 FileUtils, 522 FileWriter, 518-520 FilterlnputStream, 488, 491 FilterOutputStream, 485 Float, 251-254 Format, 421 Formatter, 511 FutureTask, 386 HashMap, 145, 356-362 HashSet, 333-337 Hashtable, 372 IdentityHashMap, 362-364 lmage, 406 lmagelcon, 408 InheritableThreadLocal, 310 InputStream, 473, 476-477 InputStreamReader, 515 Integer, 255-257 JOptionPane, 408 LineNumberInputStream, 474 LineNumberReader, 474 LinkedHashMap, 362 LinkedHashSet, 337 LinkedList, 330-332 ListResourceBundle, 402, 405 Long, 255-257 Matcher, 436 Math, 227-233 MessageFormat, 426 Method, 275-276 Number, 257 NumberFormat, 235, 421 Object, 103-112 ObjectInputStream, 497, 498 ObjectOutputStream, 497 OutputStream, 473, 475-476

OutputStreamWriter, 514 Package, 243-247 Pattern, 435

PhantomReference, 263-266 PipedlnputStream, 481, 482 PipedOutputStream, 481, 482 Preferences, 429 PrintStream, 473, 474, 508-511 PrintWriter, 474 PriorityQueue, 348-350 Properties, 372, 403, 429 PropertyResourceBundle, 402, 403 Random, 432

RandomAccessFile, 462-473 Reader, 513 ReentrantLock, 394 Reference, 259 ReferenceQueue, 259, 260 RuleBasedCollator, 414 Semaphore, 390 Short, 255-257 SimpleDateFormat, 425 SoftReference, 260-263 Stack, 372

StoppableThread, 301 StrictMath, 233-234 String, 278-281 StringBuffer, 281-284 StringBufferlnputStream, 474 StringReader, 474 StringTokenizer, 501 Subset, 142 System, 284-287 Thread, 288-289 ThreadGroup, 294 ThreadLocal, 308 Throwable, 163-164 Toolkit, 406 TreeMap, 355-356 TreeSet, 332-333 Vector, 372

WeakHashMap, 364-365 WeakReference, 263 Writer, 513

ZipOutputStream, 475 classfiles, 4

javac identifying, 7 classloader, 4, 155 ClassLoader class, 402 ClassNotFoundException, 270, 273, 506

CLASSPATH environment variable, 154,

155, 159 classpath option, 154, 155, 159 cleanup, exceptions, 172-178 clear method

BitSet class, 373 Calendar class, 418 Collection interface, 319 Map interface, 351 Reference class, 259 clearCache methods, ResourceBundle, 403 clone method

BitSet class, 373 Date class, 415 Enum class, 220 Object class, 103, 104-106 Cloneable interface, 104 CloneNotSupportedException, 104, 164 cloning deep copying/cloning, 105 shallow copying/cloning, 104 close method

FilelnputStream class, 481, 488, 491 FileOutputStream class, 488 lntputStream class, 476 OutputStream class, 475, 476 PartsDB class, 470 RandomAccessFile class, 464, 470 closed range/interval

SortedSet interface, 343 closures, 148 code see also source code agile software development, 131

converting pseudocode to Java code,

23-36 native code, 4 refactoring, 71 coercion polymorphism, 116 CollationKey class Collator API, 413 Collator class, 413 collators, 413-414

getCollationKey method, 414 RuleBasedCollator class, 414 Collection interface, 318-321 containsAll method, 319, 321 hierarchy of interfaces, 316 methods, 318-320 remove method, 319, 321 removeAll method, 320, 321

retainAll method, 320, 321 toArray methods, 320, 339, 367 collections, 315 iterating over, 322 storing primitive types in, 323 Collections class, 371-372, 434 generic methods, 212 methods, 371 performance, 372 shuffle methods, 434 collections framework, 315 Collection interface, 318-321 Comparable vs. Comparator, 316 components, 315 concurrent collections, 392-394 core interfaces, 315, 316

hierarchy, 316 generic methods, 212 generics, 200-202 implementation classes, 315, 316 Iterable interface, 318 List interface, 325-328 Map interface, 351-353 Map.Entry interface, 354-355 primitive wrapper classes, 248 Queue interface, 346-347 Set interface, 332 sorted collection, 316, 317 SortedMap interface, 367-369 SortedSet interface, 339-346 utility classes, 315, 316, 369-372 collisions hash functions, 357 command line executing JDK tools, 7 comments multiline comment, 59 preventing bugs, 181 single-line comment, 45 Four of a Kind game, 29 Comparable interface, 317 rules, 317

sorted sets, 343, 344, 345 Comparator interface, 317

methods, 317, 318 comparator method

SortedMap interface, 367 SortedSet interface, 340, 342 compare method, 318

sorted sets, 345 compareTo method

Boolean class, 248 Comparable interface, 317 sorted sets, 344, 345 using comparator with priority queue, 350

Date class, 415 Enum class, 221, 222 File class, 462 sorted sets, 345 String class, 413 type parameter bounds, 207 comparison operators, 54 compatible class change, 500 compile method, Pattern, 435, 439 compiler, Java, 4 compile-time search, 154 complement operators bitwise, 51 logical, 53 composition, 112

compound assignment operator, 52 compound expressions, 51-57 compound messages, 426, 428

formatting and outputting, 427 compound statement, 60, 95 compress method, Bitmap, 479 concat method, String, 278 concatenation string concatenation operator, 51, 55 concrete parameterized type, generics, 203 concrete type, generics, 203 concurrency utilities, 381-397, 447 atomic variables, 397 concurrent collections, 392-394 executors, 381-389 locks, 394-396 synchronizers, 390-392 concurrent collections, 392-394, 447

BlockingQueue interface, 392 ConcurrentHashMap class, 392 ConcurrentLinkedQueue class, 392 ConcurrentMap interface, 392 ConcurrentModificationException, 327 conditional AND/OR operators, 52 connect method

FileWriter class, 519 PipedlnputStream class, 482, 483 PipedOutputStream class, 482, 483 Console class, 156 Console tab, Eclipse, 20 constant interfaces, 160

constants

BigDecimal class, 236 Biglnteger class, 240 Double class, 251 Float class, 251 Locale class, 398

primitive wrapper classes, 232, 248 read-only class fields, 57 RoundingMode enum, 238 Constructor class, 274-275 constructors, 75-76, 95 see also factory methods ArrayList class, 329 BigDecimal class, 236, 239 Biglnteger class, 240 Boolean class, 248 BufferedlnputStream class, 493 BufferedOutputStream class, 493 Byte class, 255

ByteArraylnputStream class, 478 ByteArrayOutputStream class, 478 Character class, 250 Date class, 415 Double class, 251 enhancing an enum, 216 EnumMap class, 366 File class, 450, 451 FilelnputStream class, 479 FileOutputStream class, 479 FilterOutputStream class, 485 Float class, 251 getConstructors method, 270 getDeclaredConstructors method, 270 HashMap class, 358 HashSet class, 334 InheritableThreadLocal class, 310 initializing fields, 48 InputStreamReader class, 515 lnteger class, 255 LinkedList class, 331 Locale class, 398 Long class, 255 MessageFormat class, 426 OutputStreamWriter class, 514 PhantomReference class, 263 PipedlnputStream class, 482 PipedOutputStream class, 482 PriorityQueue class, 348 Random class, 432 RandomAccessFile class, 462-464 Reference class, 260

ReferenceQueue class, 260 Short class, 255 SoftReference class, 260 SortedSet interface, 340 String class, 278, 280 StringBuffer class, 282 ThreadLocal class, 309 Throwable class, 163 TreeMap class, 355 TreeSet class, 332 WeakReference class, 263 contains method, Collection, 319 containsAll method, Collection, 319, 321 containsKey/containsValue methods, Map, 351

continue reserved word, 71 continue statement, 71

labeled continue statement, 72 Control class, 403 control-flow invariants, 184-185 conversions byte cast, 56 cast operator, 56

operands of different types in operator, 56

Coordinated Universal Time see UTC

copy method, 176

copying deep copying/cloning, 105 shallow copying/cloning, 104 copylist method, generics, 209, 210, 212, 213

core interfaces, collections framework, 315, 316

cos method, Math, 228 countdown latches, 390 countDown method, 390, 391 CountDownLatch class, 390 countTokens method, StringTokenizer, 502 covariance, arrays, 211 covariant return type, 123-124 createlmage method, Toolkit, 406 createNewFile method, 459 createTempFile method, 459, 460 currency formatting numbers as, 421 NumberFormat class, 235 current method, Breaklterator, 410 currentThread method, 288, 289, 290 currentTimeMillis method, 285, 286, 415 cursor position, Listlterator, 328

cyclic barriers, 390 CyclicBarrier class, 390

Was this article helpful?

0 0

Post a comment