THE Java™ Programming Language, Fourth Edition
Exercise 1.5: Change the HelloWorld application to use a named string constant as the string to print. (A string constant can be ...
mark = ""; System.out.println(i + ": " + hi + mark); hi = lo + hi; lo = hi - lo; } } } Here is the new output: 1: 1 2: 1 3: 2 4 ...
Expressions where the value assigned to a variable is calculated from the original value of the variable are common enough that ...
Classes and interfaces can be members of other classes or interfaces (you will learn about interfaces soon). • Here is the decla ...
class. When you use new to create an object, a special piece of code, known as a constructor, is invoked to perform any initiali ...
1.8. Methods and Parameters Objects of the previously defined Point class are exposed to manipulation by any code that has a ref ...
The return statement causes a method to stop executing its body and return execution to the invoking method. If an expression is ...
1.8.3. Static or Class Methods Just as you can have per-class static fields, you can also have per-class static methods, often k ...
We declare the cards field as an array of type Card by following the type name in the declaration with square brackets [ and ]. ...
if (values == null || values.length == 0) throw new IllegalArgumentException(); Now if values is null the value of the condition ...
The concatenation operator can also be used in the short-hand += form, to assign the concatenation of the original string and th ...
Other methods for comparing subparts of strings or ignoring case differences are also covered in Chapter 13. If you use == to co ...
Additional flags in the format specifier can, among other things, request zero padding (instead of spaces) or left-justification ...
Pixel's behavior extends Point's behavior. Extended behavior can be entirely new (adding color in this example) or can be a rest ...
In this example, oref is correctly assigned references to Pixel and String objects even though those classes have no relationshi ...
the interface and declares what those methods should do. Here is a Lookup interface for finding a value in a set of values: inte ...
supertypes, including interfaces. An object can be used polymorphically with both its superclass and any superinterfaces, includ ...
Class IntegerLookup is not itself a generic class, rather it implements a generic interface, providing a concrete typeIntegerin ...
if (value != null) processValue(names[i], value); } } Where? on its own is the unbounded wildcard, that can represent any type, ...
public double[] getDataSet(String setName) throws BadDataSetException { String file = setName + ".dset"; FileInputStream in = nu ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf