P

Package class, 243-247, 268 Package Explorer tab, Eclipse, 19 package reserved word, 152 package statement, 152-153, 179 Packagelnfo application, 244-247 package-private access control level, 83 package-private methods including in Javadoc documentation, 36 packages, 151-160

see also Java packages compile-time search, 154 getPackage method, 271 import statement, 153-154 JAR files, 159-160 logging library example, 155-159 namespaces, 151 naming conventions, 152 package statement, 152-153 runtime search, 155 sealed packages, 243 isSealed method, 244

searching for packages and types, 154155 storing, 154 unnamed package, 153 paragraph separator line terminator, 439 @param, Javadoc tag, 35 parameterized types, generics, 201, 202 concrete parameterized type, 203 wildcards, 208 parameters getParameterTypes method, 275 methods, 58, 61 parametric polymorphism, 116 parent class see superclass parent thread, 310 parentheses operator precedence, 55 parseBoolean method, 249 parseDouble method, 252, 254 parseFloat method, 252, 254 parseObject methods, 421 PartsDB class, 467, 470 pass-by-value argument passing, 91 path, 450 pathnames, 450

absolute pathname, 451 compareTo method, 462 getAbsoluteFile method, 452 getAbsolutePath method, 452 getCanonicalPath method, 452 getPath method, 452 isAbsolute method, 453 methods for learning about stored pathname, 452 obtaining abstract pathname information, 453 relative pathname, 451 separator character, 451 Pattern class, 435

compile method, 435, 439 line terminators, 439 matcher method, 435, 436 methods, 435 pattern matching capturing groups, 440 pattern method, 435 patterns, 426

apostrophe in, 427 applyPattern method, 428 Matcher class, 436

matching text against, 434 messages, 426 metacharacters, 434 quantifiers, 442 ResourceBundle class, 401 PatternSyntaxException, 435, 436, 437 peek method, Queue, 347 percentages, formatting numbers as, 421 performance

Collections class, 372 reflection, 269 threading, 296, 301, 302 threads, 287

unlimited serialization, 497 using StringBuilder not StringBuffer, 284 period metacharacter, 438 phantom reachable objects, 258 PhantomReference class, 263-266, 268

phantom reachable objects, 258 PI constant, 227

PipedlnputStream class, 481, 482 PipedOutputStream class, 481, 482 platforms

Android platform, 5 Java, 3

Java EE (Enterprise Edition), 5 Java ME (Micro Edition), 5 Java SE (Standard Edition), 5 plus unary plus operator, 55 Point class equals method, 107 pointers, 3 poll method

BlockingQueue interface, 396 Queue interface, 347, 349 ReferenceQueue class, 260, 265 polymorphism, 116-124

coercion polymorphism, 116 downcasting, 121-123 generics, 208

overloading polymorphism, 116 parametric polymorphism, 116 runtime type identification, 121-123 subtype polymorphism, 117 pooling implementing object pools, 264 pop method-call stack, 90 stack, 225 pop method, Stack, 372

portability hard-coding \n escape sequence, 509 Java, 4

Java applications, 46 strictfp reserved word, 233, 234 positive unary plus operator, 55 POSITIVE_INFINITY constant, 251 testing float/double for equality with +infinity, 253 possessive quantifier, 442, 443, 444 postconditions design-by-contract development, 187188

postdecrement operator, 53 postfix operator, 51 postincrement operator, 54 precedence, operators, 55 preceding method, BreakIterator, 411 precision, decimals, 235 precision method, BigDecimal, 237 preconditions design-by-contract development, 185187

predecrement operator, 54 predefined character classes, 440 preemptive scheduling, 291 preferences, 428

java.util.prefs package, 429 storing in Windows XP registry, 430, 431 system preference tree, 429 Preferences APIs, 428-431 Preferences class, 429 methods, 429-430 prefix operator, 51 preincrement operator, 54 previous method

BreakIterator class, 411 ListIterator class, 327, 328 previousIndex method, ListIterator, 327, 328 primitive types, 46

autoboxing and unboxing, 323 portability of Java applications, 46 storing in collections, 323 primitive wrapper classes, 247-257, 268 Boolean class, 248-250 Byte class, 255-257 Character class, 250-251 constants, 232 Double class, 251-254 Float class, 251-254

Integer class, 255-257 Long class, 255-257 Short class, 255-257 storing primitive types in collections, 323 superclass of, 257 print method

PrintStream class, 508 System.out, 9, 509 printf method

PrintStream class, 509

format specifiers, 510 System.out, 510 println method

PrintStream class, 508 System.out, 9, 509, 511 printStackTrace method, Throwable, 164, 168

PrintStream class, 473, 474, 508-511 checkError method, 511 flush method, 511 print method, 508 printf method, 509

format specifiers, 510 println method, 508 System.err, 508 System.out, 508 PrintWriter class, 474 priority setPriority method, 291 priority queues, 346, 348 PriorityQueue class, 348-350 private access control level, 83

inheritance, 100 private reserved word, 83 problem domain

Four of a Kind application, 21 profiling, 132

projects area, NetBeans IDE, 15 projects directory, JDK, 7 Projects tab, NetBeans IDE, 15 properties getProperty method, 285, 286, 372 setProperty method, 372 Properties API, 429 Properties class, 372, 375, 429 properties files, 403 property resource bundle, 403-405 PropertyResourceBundle class, 402, 403 protected access control level, 82 protected reserved word, 82 pseudocode, 21

converting to Java code, 23-36 modeling Four of a Kind in, 21-23 public access control level, 82, 83

accessing fields, 88 public methods when not to use assertions, 188 public reserved word, 82 interfaces, 126 main method, 60 push method-call stack, 90 stack, 225 push method, Stack, 372 put method

BlockingQueue interface, 393, 396 Map interface, 352 Preferences class, 430 putAll method, Map, 352 putBack method, Four of a Kind game, 28

quantifiers, 442-444

greedy quantifier, 442, 443 possessive quantifier, 442, 443, 444 reluctant quantifier, 442, 443 zero-length matches, 443 queue data structure, 204 Queue implementation classes, 347 Queue interface, 346-347

BlockingQueue subinterface, 392 hierarchy of interfaces, 316 methods, 346-347 PriorityQueue class, 348-350 queues, 346

first-in, first-out (FIFO), 346 last-in, first-out (LIFO), 346 priority queues, 346, 348 PriorityQueue class, 348-350 Queue<E> generic type, 203-205 quote method, Pattern, 435 quotes, escape sequences for, 49

r mode argument

RandomAccessFile constructor, 463 race condition, threads, 298 Random class, 432-434 methods, 433-434

random method, Math class, 229, 231, 432 random number generation, 432-434, 447

seed value, 432 RandomAccessFile class, 462-473 close method, 464, 470 constructors, 462-464 creating flat file database, 467-472 file pointer, 464 getFD method, 464, 465, 466 methods, 464-465 read-prefixed methods, 466 skipBytes method, 465, 466 write-prefixed methods, 466 range character class, 439 range method, EnumSet, 339 range-view operations List interface, 328 Rank enum, Four of a Kind game, 26, 34 Rank object, Four of a Kind game ordinal method, 34 rank method, Four of a Kind game, 26 rankCounts array, Four of a Kind game, 34 raw type, generics, 203 reachable objects, 258 read method

BufferedlnputStream class, 492, 493 FilelnputStream class, 488, 489, 490,

491,492 InputStreamReader class, 515 lntputStream class, 477 RandomAccessFile class, 464 Reader class, 513, 514 System.in, 10 readChar method, RandomAccessFile, 464 Reader class, 513

read method, 513, 514 ready method, 514 reader classes, 512-513 BufferedReader class, 522 FileReader class, 520-522 InputStreamReader class, 515 readers (and writers), 511-529 readExternal method, 506, 508 readlnt method, RandomAccessFile, 465 readLine method, BufferedReader, 522 readObject method, ObjectlnputStream,

497, 498, 500, 505, 507, 508 read-only fields, 57-58 ready method, Reader, 514 recursive calls, methods, 90 recursive type bound, generics, 208

ReentrantLock class, 394 refactoring, 71 Reference class, 259-260 reference classes

PhantomReference class, 263-266 SoftReference class, 260-263 WeakReference class, 263 reference variable, 86 Reference<T> generic type, 259 referenced objects garbage collection, 92 identity check, 106 ReferenceQueue class, 259, 260 ReferenceQueue<T> generic type, 260 References API, 257-266, 268 references, root set of, 257 reflection identifying class members, 272 performance, 269 Reflection API, 269-277 Class class, 270-274 reflexive rule

Comparable interface, 317 region method, matchers, 437 regionEnd method, 437 regionStart method, 437 regular expressions, 434, 437-444 boundary matchers, 441-442 capturing groups, 440-441 character classes, 439-440 matching phone numbers, 444 matching text against patterns, 434 metacharacters, 434, 438 predefined character classes, 440 quantifiers, 442-444 Regular Expressions API, 434-447 reification, generics, 211 RejectedExecutionException, 382 relational greater than operator, 54 relational less than operator, 54 relational type checking operator, 54 relationships

"has a" relationship, 112 "is a" relationship, 98 relative pathnames, 451 reluctant quantifier, 442, 443 remainder method

BigDecimal class, 237 Biglnteger class, 241 remainder operator, 54 remove method

Collection interface, 319, 321 Iterator class, 321 List interface, 326 Listlterator class, 327 Map interface, 352 Queue interface, 347 ReferenceQueue class, 260 ThreadLocal class, 309 removeAll method, Collection, 320, 321 renameTo method, File, 460 replace method, String, 279 ReportCreationException, 171 reserved words getModifiers method, 276 list of reserved identifiers, 44 primitive types, 46 reserved words, list of abstract, 121 assert, 182 break, 65, 70 case, 65 catch, 168 continue, 71 default, 65 do, 69 else, 62 enum, 215

extends, 98, 130, 205 false, 49 final, 57

implements, 127 import, 153 instanceof, 54 int, 45

interface, 125 module, 159 native, 492 new, 53 package, 152 private, 83 protected, 82 public, 82 return, 73 static, 48 strictfp, 233 super, 99, 207 switch, 64 synchronized, 394

this, 76, 85 throw, 167 throws, 110, 167 true, 49 try, 110 void, 59

volatile, 302, 303 while, 67 reset method

IntputStream class, 477 Matcher class, 437, 522 resource bundles, 400-409 accessing resources, 403 candidate bundle names, 401, 402 Control class, 403 list resource bundle, 405-409 ListResourceBundle class, 402 properties files, 403 property resource bundle, 403-405 PropertyResourceBundle class, 402 resource management, automatic, 176 resource-access methods, 403 ResourceBundle class, 401 clearCache methods, 403 getBundle methods, 401, 402 setParent method, 402 resurrection, 264

implementing object pools, 264 retainAll method, Collection, 320, 321 Retention meta-annotation type, 196, 197 RetentionPolicy enum, 196 return (carriage return)

escape sequence for, 49 @return, Javadoc tag, 35 return reserved word, 73 return statement method return, 73-74 return type covariant return type, 123-124 getReturnType method, 276 methods, 58 reverse method

Collections class, 371 StringBuffer class, 283 right shift operators signed, 54 unsigned, 55 rnd method, Math, 186

converting random() return value, 231 root directories listRoots method, 449

root directory, Windows backslash representing, 159 root set of references, 257 round method, Math, 229

BigDecimal floating-point calculations, 234

round robin scheduling, 291 ROUND_-prefixed constants

BigDecimal class, 236 rounding, decimals setScale method, 237 RoundingMode enum, 237 RSA encryption

Biglnteger class, 243 RTTI (runtime type identification), 121-123

marker/tagging interface, 126 RuleBasedCollator class, 414 run method, Runnable interface, 288, 290, 382, 385 countdown latches, 391 runFinalization method, System, 285 Runnable interface, 288, 382

Executor interface limitations, 382 run method, 288, 290, 382, 385 runnable tasks, 382 execute method, 382 submit method, 384 RUNNABLE value, State enum, 288 runtime exceptions, 165 RUNTIME retention policy, 196, 197 runtime search, 155 runtime type identification see RTTI RuntimeException, 165, 179 rw/rwd/rws mode arguments

RandomAccessFile constructor, 463

Was this article helpful?

0 0

Post a comment