DOC PREVIEW
Berkeley COMPSCI 61B - A Java Reference

This preview shows page 1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-123-124-125-126-127-128-129-130-131-132-133-134-135-136-137-138-139-247-248-249-250-251-252-253-254-255-256-257-258-259-260-261-262-263-264 out of 264 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 264 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Java OverviewBasic Program StructureCompilation and ExecutionSimple Values and ExpressionsWriting NumbersArithmeticComparisons and Logical OperationsStringsStatic Methods: Abstracting ComputationConditional ExecutionIf statementsConditional ExpressionsCase analysis and the Switch StatementArrays I: The Command LineExample: Finding PrimesStarting from the topStarting from the bottomMeeting in the middleExample: Pig LatinVowelsTranslationCounting ConsonantsTo the topVariables and AssignmentRepetitionIndefinite iterationDefinite IterationExample: Iterative Prime-FindingExample: CountingArrays II: CreationExample: Linear InterpolationExample: The Sieve of EratosthenesMulti-dimensional ArraysIntroduction to ObjectsSimple Object Type Definition and CreationInstance MethodsConstructorsExample: A Prime-Number ClassInterfacesInheritancePackages and Access ControlHandling Exceptional CasesBuilt-in ExceptionsWhat Exactly is an Exception?Throwing Exceptions ExplicitlyCatching ExceptionsDescribing a Programming LanguageDynamic and Static PropertiesDescribing Lexical Structure and SyntaxLexical BasicsLayout: Whitespace and CommentsValues, Types, and ContainersValues and ContainersContainers and NamesPointersTypesStatic vs. dynamic typesType denotations in JavaEnvironmentsApplying the model to JavaDeclarationsScope and the Meaning of NamesBlock structureSelectionPackages and ImportsLocal VariablesType DeclarationsClass DeclarationsKinds of class membersInheritanceClass ModifiersFieldsInterface DeclarationsEnumerated TypesNested Classes and InterfacesMember typesLocal classesAnonymous classesWhat on earth is this all for?Method (Function) DeclarationsVariable-Length Parameter ListsMethod signaturesOverloading and hiding methodsOverridingConstructor DeclarationsRationale.Instance and field initializersSome Useful Constructor IdiomsInitialization of ClassesAccess controlThe Java ProgramExecuting a ProgramAnnotationsDeprecatedOverrideSuppressWarningsThe Expression LanguageSyntactic overviewPrefix, Postfix, and Infix OperatorsLiteralsConversions and CastsExplicit conversionsImplicit conversionsPromotionsIntegers and CharactersIntegral values and their literalsModular integer arithmeticManipulating bitsFloating-Point NumbersFloating-Point LiteralsFloating-point arithmeticBooleans and ConditionalsBoolean literalsBoolean operationsComparisons and EqualityConditional expressionsReference TypesAllocating class instancesField AccessTesting typesArraysStringsAssignment, Increment, and Decrement OperatorsMethod CallsStatic method callsInstance Method CallsConstant ExpressionsReflectionType java.lang.ClassDefinite Assignment and Related Obscure DetailsAssignments to fieldsBlank final variablesStatementsSequencing, Blocks, and Empty StatementsConditional ControlIf StatementsSwitch StatementsAbout Statement FormatIterationWhile LoopsTraditional For LoopsFor Loops for Collections and ArraysJump Statements and LabelsThe `break' StatementThe `continue' StatementThe `return' StatementException HandlingThrow Statements and Exception TypesCatching Exceptions: Try StatementsSimple example: single handlerMultiple handlers.Using the Caught Exception.The Finally ClauseDeclaring Thrown ExceptionsExceptions in the java.lang PackageStrings, Streams, and PatternsBytes and CharactersASCII and UnicodeThe class CharacterStringsConstructing StringsString AccessorsString Comparisons, Tests, and SearchesString HashingStringBuildersReaders, Writers, Streams, and FilesInputReaders and InputStreamsOutputPrintStreams and PrintWritersRegular Expressions and the Pattern ClassScannerGeneric ProgrammingSimple Type ParametersType Parameters on MethodsRestricting Type ParametersWildcardsGeneric Programming and Primitive TypesFormalitiesCaveatsMultiple Threads of ControlCreating and Starting ThreadsA question of terminologySynchronizationMutual exclusionWait and notifyVolatile storageInterruptsIndexA Java ReferencePaul N. HilfingerUniversity of California, BerkeleyCopyrightc 2001, 2002, 2004, 2006, 2008, 2011 by Paul N. Hilfinger. All rightsreserved.Acknowledgments. Many thanks to Soheil Golshan, Benson Limketkai, VadimPerelman, Barath Raghavan, Michael Yang, and Asa Daniel Zernik for finding m anyerrors in previous editions of this document. Remaining errors are, of course, myown.Contents1 Java Overview 91.1 Basic Program Structure . . . . . . . . . . . . . . . . . . . . . . . . . 91.2 Compilation and Execution . . . . . . . . . . . . . . . . . . . . . . . 111.3 Simple Values and Expressions . . . . . . . . . . . . . . . . . . . . . 121.3.1 Writing Numbers . . . . . . . . . . . . . . . . . . . . . . . . . 121.3.2 Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.3.3 Comparisons and Logical Operations . . . . . . . . . . . . . . 141.3.4 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161.3.5 Static Methods: Abstracting Computation . . . . . . . . . . . 171.4 Conditional Execution . . . . . . . . . . . . . . . . . . . . . . . . . . 181.4.1 If statements . . . . . . . . . . . . . . . . . . . . . . . . . . . 191.4.2 Conditional Expressions . . . . . . . . . . . . . . . . . . . . . 191.4.3 Case analysis and the Switch S tatement . . . . . . . . . . . . 191.5 Arrays I: The Command Line . . . . . . . . . . . . . . . . . . . . . . 211.6 Example: Finding Primes . . . . . . . . . . . . . . . . . . . . . . . . 221.6.1 Starting from the top . . . . . . . . . . . . . . . . . . . . . . 231.6.2 Starting from the bottom . . . . . . . . . . . . . . . . . . . . 231.6.3 Meeting in the middle . . . . . . . . . . . . . . . . . . . . . . 261.7 Example: Pig Latin . . . . . . . . . . . . . . . . . . . . . . . . . . . 281.7.1 Vowels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281.7.2 Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291.7.3 Counting Consonants . . . . . . . . . . . . . . . . . . . . . . 291.7.4 To the top . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311.8 Variables and Assignment . . . . . . . . . . . . . . . . . . . . . . . . 321.9 Repetition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341.9.1 Indefinite iteration . . . . . . . . . . . . . . . . . . . . . . . . 351.9.2 Definite Iteration . . . . . . . . . . . . . . . . . . . . . . . . . 371.9.3 Example: Iterative Prime-Finding . . . . . . . . . . . . . . . 401.9.4 Example: Counting . . . . . . . . . . . . . . . . . . . . . . . 411.10 Ar rays II: Creation . . . . . . . . . . . . .


View Full Document

Berkeley COMPSCI 61B - A Java Reference

Documents in this Course
Lab

Lab

4 pages

Matrix

Matrix

3 pages

Numbers

Numbers

14 pages

Lectures

Lectures

12 pages

Project 1

Project 1

24 pages

Exam

Exam

8 pages

Load more
Download A Java Reference
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view A Java Reference and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view A Java Reference 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?