` Exhibit 1025 Page 1 SYMANTEC
`
`
`
`
`l’l‘l3|
`
`We have desigr
`language. It set
`for pursuing ad
`with object—oric
`ment high-qua]
`This text v
`
`gramming and
`ground up, witl
`emerged in mic
`Web effects. Ov
`object—oriented
`discovered that
`ing concepts wl'
`In response
`nary version. Si
`ing topics to [:
`students betterg
`embrace java 1.
`earlier version, i
`
`Object—Oriem
`We introduce 0]
`out. We have f(
`
`they are present
`
`Editor-in—Chief
`Associate Editor
`Production Manager
`Production Editor
`Marketing Manager
`Compositor
`Technical Artist
`Copyeditor
`Text Design
`Indexer
`Proofreading
`Cover Designer
`
`Lynne Doran Cote
`Deborah Lafferty
`Karen Wernholm
`Amy Willcutt
`Tom Ziolkowski
`Michael and Sigrid Wile
`George Nichols
`Roberta Lewis
`Ron Kosciak
`Nancy Fulton
`Phyllis Coync ct al.
`Diana Coe
`
`i 3 i 5 I l I l i l
`
`Library of Congress Cataloging-in—Publication Data
`Lewis, John, Ph.D.
`java software solutions : foundations of program design / John
`Lewis, William loftus.
`p.
`cm.
`Includes index.
`ISBN 0-201-T164-1
`
`2. Object-oriented
`1. java (Computer program language
`programming (Computer science)
`I. Lottus. William.
`II. Title.
`QA76.73._]38I.49
`I998
`OO5.13‘3——dc21
`
`97-19400
`CIP
`
`Many of the designations used by nianutacturers and sellers to distinguish their
`products are claimed as trademarks. \\"here those designations appear in this book.
`and Addison—Wesle_v was aware of a trademark claim, the designations have been
`printed in initial caps or all caps.
`
`Cover image © Jerry Blank/SIS
`
`Access the latest information about AddisonA\\i'esley titles from our World Wide
`Web site: http://www.awl.com/cseng
`Reprinted with corrections, Jarzuary 1998.
`
`Copyright© 1998 by Addison Wesley Longman, Inc.
`
`All rights resetved..~N art of this publication may be reproduced, stored in a
`retrieval system, or transm tted, in any form or by any means, electronic, mechani-
`cal, photocopying, recordirig, or otherwise, without the prior written permission of
`I
`the publisher. Printed in the United States of America.
`
`6 7 8 9 10-MA5o1oo9998
`
`
`
`SYMANTEC Exhibit 1025 Page 2
` Exhibit 1025 Page 2 SYMANTEC
`
`
`
`
`4.4 Defining Methods
`7
`.o.ses.ge§.u-u._a<,.a»g,ags~sg.=g..,.v,.n.——.sae=aa«—»aa~» /
`
`We’ve already used many methods in various programs and we know that methods
`are part of a class. Let’s now examine method definitions closely in preparation for
`defining our own classes.
`A method is a group of programming language statements that are given a
`name. A method is associated with a particular class. Each method has a method
`definition that specifies the code that gets executed when the method is invoked.
`We’ve invoked the println method many times, but because we didn’t write
`println, we have not been concerned about its definition. We call it assuming that
`it will do its job reliably.
`When a method is called, the flow of control transfers to that method. One by
`one, the statements of that method are executed. When that method is done, control
`returns to the location where the call was made and execution continues. This
`process is pictured in Fig. 4.4.
`We’ve defined the main method of a program many times. Its definition fol-
`lows the same syntax as all methods:
`
`return—type method-name
`stat:ement—list
`
`( parameter—1ist
`
`)
`
`{
`
`The header of a method includes the type of the return value, the method name, and‘
`a list of parameters that the method accepts. The list of statements that makes up the
`
`methodl
`
`
`
`body of the method are
`method called third_r
`
`'.:::
`
`third_power (int
`int cube;
`cube = number * n
`return cube;
`// method third__p
`
`A method may dec
`inat method. The vari
`method. Local variable
`other methods of the s:
`the main method. The:
`so not exist except wh
`Local variable is lost fr(
`'-value to be maintained
`' Lie class level. The dec
`
`I
`
`;st. but it must be decl:
`
`
`
`Key Concept A Var
`used outside of it.
`a._&sg..1a:a...se
`
`The return sta1
`
`Methods can return a
`zethod header. The re
`‘Ihen a method does n(
`
`tape, as is always done
`: the method header. T
`
`Saturn;
`
`Figure 4.4 The flow of control following method invocations
`
`Fturn expressioz
`
`134 Chapter 4 Objects and Classes
`
`
`
`SYMANTEC Exhibit 1025 Page 3
` Exhibit 1025 Page 3 SYMANTEC
`
`
`
`
`
`
`body of the method are defined in a block. The following code is the definition of a
`method called third__power:
`
`ethods
`on for
`,
`
`wen a
`zet/aod
`
`’Oke,d‘
`Wme
`g that
`me by
`p
`
`'
`
`n fol‘
`
`_’ and
`.p the
`
`‘.2:
`
`third_power (int number)
`int cube;
`cube = number * number
`return cube;
`
`{
`
`* number;
`
`// method third_power
`
`A method may declare local variables in the body of the method for use only in
`that method. The variable cube in the third_power method is local
`to that
`method. Local variables cannot be accessed from outside of the method, even from
`other methods of the same class. In previous examples yve’\'e declared variables in
`the maln method. These variables were local to the maln method. Local variables
`do not exist except when the method is executing; therefore the value stored in a
`local variable is lost from one invocation of the method to the next. If you want a
`value to be maintained from one call to the next, you should define the variable at
`the class level. The declaration of a local variable can be mixed into the statement
`list. but it must be declared before it is used.
`
`A variable declared in a method is local to that method and cannot be
`» Key concept
`used outside of it.
`
`r.,,....r.
`
`,.
`
`..
`
`..
`
`.
`
`.
`
`_.rr,-.,Mr.rr..,.,_._._.r..r fl.;,,_.._.._,_.,. .r.._... ..._-,..,...m...,,,,...-_.
`
`The return statement
`
`Methods can return a value, whose type must correspond to the return type in the
`method header. The return type can be a primitive type or a reference to an object.
`When a method does not return any value, the reserved word void is used as the return
`type, as is always done with the main method. A return type must always be specified
`in the method header. The return statement in a method can take one of two forms:
`
`return;
`
`01‘
`
`return expressi on;
`
`4.4 DefiningMethods
`
`135
`
`SYMANTEC Exhibit 1025 Page 4
` Exhibit 1025 Page 4 SYMANTEC
`
`
`
`
`The first form causes the processing flow to return to the calling location without
`returning a value. The second form returns to the calling method and specifies the
`value that is to be returned. If a return type other than void is specified in the
`method header, then the Java compiler insists that a return statement exist in the
`program and that a value of the proper type is returned.
`
`D
` Key Concept A method must return a value consistent with the return type specified in
`the method header.
`
`The following code is another way to define the third_power method, per-
`forming a calculation in the expression of the return statement. This modification
`eliminates the need for the local variable.
`
`{
`int third_power (int number)
`return (number * number * number);
`// method third_power
`
`)
`
`If there is no return statement in a method, processing continues until the end
`of the method is reached. If there is a return statement, then processing is stopped
`for that method when the return statement is executed, and control is returned to
`the statement that invoked the method.
`
`It is usually not good practice to use more than one return statement in a
`method even though it is possible to do so. In general, a method should have one
`return statement as the last line of the method body unless it makes the method
`overly complex.
`
`Parameters
`
`A parameter is a value that is passed into a method when it is invoked. The parame-
`ter list in the header of a method specifies the types of the values that are passed and
`the names by which the called method will refer to the parameters in the method
`definition. In the method definition, the names of the parameters accepted are called
`formal parameters. In the invocations, the values passed into a method are called
`actual parameters. A method invocation and definition always specify the parameter
`list in parentheses after the method name. If there are no parameters, an empty set of
`parentheses are used.
`The formal parameters are identifiers that essentially act as local variables for
`the method and whose initial value comes from the calling method. Actual parame-
`
`ters can be literals.
`
`passed as the paran
`
`public void acid
`String title
`generate_repo
`// method acb
`
`This example is a
`invoking another 1*
`acid_test are 5'
`Note that substa
`method invocation
`in acid_test,
`;enerate_repor
`
`When primitivt
`meter. When objects
`[0 the actual parami
`parameter becomes
`Java, primitive data
`
`I
`
`D
`
`Key Concept A
`Therefore the actt
`
`Lct’s look at an
`we have a class Nun
`
`gram demonstrates
`
`Demonstrates!
`class Parameter_]
`
`public static
`(int formai
`Nmimma
`
`System.out
`out
`System.
`out
`System.
`out
`System.
`
`136 Chapter 4 Objects and Classes
`
`
`
`SYMANTEC Exhibit 1025 Page 5
` Exhibit 1025 Page 5 SYMANTEC
`
`
`
`
`
`
`thout
`:s the
`n the
`n the
`
`ed in
`
`per-
`tion
`
`:nd
`)ed
`IO
`
`1 8
`>UC
`0d
`
`1d
`
`o.o'_r3_
`
`rers can be literals, variables, or full expressions that are evaluated and the result
`passed as the parameter. Let's look at an example:
`
`public void acid_test (int substancel, float substance2)
`String title : “Acid Test Order Form”;
`generate_report (title, substancel, substance2);
`// method acid_tes:
`
`{
`
`This example is a method called acid_t:est:. The method generates a report by
`invoking another method called ger1erate_report. The formal parameters for
`aciditest; are substancel and substarice2, as listed in the parameter list.
`Note that substancel and substance2 also serve as actual parameters to the
`method invocation of generate_report. The variable title is a local variable
`in
`ac id_tes t.
`and
`serves
`as
`an
`actual
`parameter
`for
`the
`call
`to
`ger1erate_report.
`
`When primitive data is passed. a copy of the value is assigned to the actual para-
`meter. When objects are passed. a copy of the reference to the original object is assigned
`to the actual parameter. Therefore when an object is passed as a parameter, the formal
`parameter becomes an alias of the actual parameter. Another \va_v to sa_v this is that, in
`java, primitive data is passed by value and objects are passed by reference.
`
`
`
`
`
`is used as a parameter.
`IS passed by reference when it
`Key Concept An object
`Therefore the actual parameter and the formal parameter are aliases of each other.
`
`Lets look at an example that tests the issue of parameter passing. Assume that
`we have a class Nurn that contains an int variable called value. The following pro-
`gram demonstrates passing the various data types:
`
`// Demonstrates the effects possible using parameter passin
`class Parameter_Passing {
`
`public static void char:ge_*/alues
`(int formall,
`int forma:2, Num formal},
`Num formal4, Num formali)
`{
`
`System.out. rintlntl;
`System.out.println ("Before changing values");
`System.out.println ("Formal parameter 1:
`+ formalll;
`System.out.println ("Formal parameter 2:
`+ forma12\;
`
`4.4 Defining Methods
`
`137
`
`SYMANTEC Exhibit 1025 Page 6
` Exhibit 1025 Page 6 SYMANTEC
`
`
`
`
`
`
`l:x.1rtiple< have hcen kept simple. focused. and
`"The bunk is El _ir,nnrl tine.
`useful. This is iniporiiint to hold ii .stiitlem's nttemimi. The hunk l\ l7.\sL‘ll
`on ‘IDK l.l. which is J more miiture AW than the earlier versioii. It clues
`A good inh 0|’ il1l’l'OlluClI1}..‘, proizraiiniiiing; principles in _I;i\‘ii.“
`—\‘ii-.iv sTil1i\‘t\§:|ll,_ld\‘al§0lil. Sun l\lierus_vstenis, Inc.
`
`
`
`Mini 1 mt ,\I,'|H(lR\
`
`lohn Lewis is All] /\s5ist'.1nt l’i't>less(>r of (Inmpiirer
`Science at Vlll:1n()\';1 l|ni\ersit_\'. Dr. Lewis received
`hix l’h.D. tmin Vir_s_;ini;i Tech in 1991. His L1F€L1()f
`~.peciiili'/.iitiun is .s<>ft\\'.ii'e eiigiiieeriiig, and he reg
`iil.irh teaches coiirses in lnI'I'()(lLlLT()F_\' cniiipiitiiig,
`s'ntt\v;ii‘e t‘Hgll1Lft‘l'll]_L1,()l\jCCl-()l‘lCI1fCtl(lC%lQ11,()pL‘l'-
`iiting systems, and iilgoritliiiis C\'
`(lzlfll SIl‘UL‘I'Lll‘t’.S.
`Dr.
`l.€\\’I\
`IS -.1 menilier (ll
`the .'\(IM,
`the llllill
`konipiiter Society, and Sigmii Xi,
`the scientific
`iexeiircli society He i5 Also the (itmliereiice (Ihiiir
`for the N98 SKQCSF. Technical S_\'mp0siiiiii,
`\l(’illiam loltus is the Tecliiiiciil l)irectt)r of \‘Vl’l,
`l..iliui‘;1toi‘ies, Inc. where he directs ll1L1l1_\' Sl)ll\Vi1I’(‘
`(lL‘\'Cl()pIl1t‘l1l and research pmjects. He is it liiglily
`respected expert
`in the iirezis of nhiect~t)i'ieiiIed
`5)’5tCIH$ develtipnieiit and suftwiire CI1§.§ll1CCI‘ll1g.
`He has perstiiizilly cnnsiiltetl to in;i_i
`Fortune 500
`L‘()l11p.”lH;]“'
`3’-*¥
`"M ‘:'JUK':_.'WK»-e
`5,
`(i()m'
`pnter Se
`Q
`9'1/l"
`l)dCl(.'ll‘(.l.
`‘I
`‘
`Previoiis
`iiuii 5ni.n.«Rij
`1
`lJiiis_vs.
`“
`He has
`M
`A\v;ii‘d
`ii
`lit
`l-F0111 D.-3
`lil i"“';*\
`' Actioii
`
`/\Wz1rLl5.
`" m .
`,.
`lllhl
`l
`ill!
`in”
`'
`:
`t"Di'“))
`2i11—l17l3:l'3
`.L'.;$.. uiiormation about Addisnivweslcy
`Access th:
`hooks at uur Wiirld Wide Web s
`http://www.afi' i
`“ii
`I:
`
`l
`I
`
`l l
`
`M;
`
`Imilli
`
`
`
`I
`
`john Lewis, Villanova University
`William Loftiis, WPL Laboratories. Inc.
`
`l. I. _/tiiii ht)/‘fl('il)'(’ .81’:/1m'mi_< It".!Cl1L‘.\
`Using _];1\;1
`heginniiig prograniineiis how to &l(‘SlgI1 and
`iniplement
`liii_;li—qiizi|it_\' <>h]ect—0rientcd SUN’-
`wzirc. The antlmrs (‘l11pl‘I;1§lZ(.‘ pmhlem \l)l\'ll1_{1
`thmiigh UllLlCt‘SI';ll1Llll1g l'€L[llll‘L‘l]1L’I1[S,
`e.\pl(iriii;;
`options, and desigiiing L‘()IlC€ptll:lll_\’ clean solu-
`tioiis.
`john Lewis and Bill
`lnftiis wrote this
`lmok fmin the ground up. tiiking Full
`;1Ll\';ll1l'<1}J,C
`of java to tciich iiiti‘odiict<>i‘_v pi‘<)gi‘aiiiiiiiiig.
`Tlirmiglioiit the htiok, the ;1Utl10I‘$ intertwine the
`use of applets iintl L1DpliC'.l[l()ll\
`(lCI11()l]§l"I‘;‘ll'(‘
`computing cmicepts. Applets are introduced
`early, hiiiltliiig on the e\'eitenient of the web.
`while klppllCilIlUll.S help readers gain .1 Clt"c1l'
`Liiideiistiiiidiiig of pmg,i';1iiiniing concepts.
`Hi(;Hi.ic;H rs
`
`0 Presents objects early and i‘eiiitoi‘ce.» the
`design principles of <)hject—()rieiitetl prngr;iiii-
`niing throtighmit
`
`' (i()ml3lIl(.‘5 Snlzlll, readily lll]LlL’l‘SfL1l1(.l&.1l3lL'
`exriniples with larger, pI‘i1CtlCi1l ones to explore
`J \'fll'lt‘l')' of pmgrnim
`
`0 l’rm'ides‘ 21 diverse wealth of self—i'e»iew
`qiieitiuiis. exercises, prtigriiiiiiiiiiig projects
`nnd clear chapter tihiectives
`
`I (:()!1YaliI1S_I2l\/3 reference iniiterial, ll1ClLlLllIlg
`I5 appendices that emitiiiii style guidelines
`and more
`
`,A, ADDISON-WESLEY
`
`Addison—We5ley is an imprint
`of Addison Wesley Longman, Inc.
`
`
`
`
`
`_t v _.
`ii8‘ni";1_.g3.0’
`18""
`i~ai:iJ.-Ii-'-*~i.i.'u3’i'--«.»‘=_.-fit
`
`; S
`
`YMANTEC Exhibit 1025 Page 7
` Exhibit 1025 Page 7 SYMANTEC