Recent Bookmarks and Annotations
-
Chemistry : Chapter 1 : Overview on 2009-11-22
-
Therefore the study of chemistry includes
any thing. One of the few examples of nonmatter is energy,
such as heat and light. However, most changes in matter include
changes in energy, and chemists also study the energy that accompanies
the changes in matter.
-
Physical
properties include such qualities as color, size, and luster.
Chemical properties are observed when matter actually changes its identity. For example,
a chemical property of water is that electricity can transform it
into oxygen gas and hydrogen gas.
-
-
Mixtures can be
separated physically, that is, the components can be separated without
changing their identity.
-
On the other hand,
pure
substances cannot be separated physically. If a pure substance
is separated—and this is not always possible—it is separated
chemically, yielding the same ratio of the components every time;
these components have a different identity than when they were first
combined.
-
Homogeneous
mixtures have a uniform composition. Sugar and water provide
an example of this. Whatever portion of the mixture is sampled will
have the same characteristics. The composition of
heterogeneous
mixtures depends on the location within the mixture.
-
Compounds
can be separated chemically, divided into two or more components.
However, these components will differ in identity from the compound
and from each other. The identity and mass ratio of these components
will be the same in a specific compound. For example, water can
be chemically divided into hydrogen and oxygen, and the oxygen produced
will always weigh eight times more than the resulting hydrogen.
-
Protons are positively charged particles with a mass of about 1
atomic
mass unit (amu). The identity of an element is defined as
its number of protons. The number of protons is also called an element's
atomic number (
Z) and is listed with the element in the periodic table.
Atoms are electrically neutral, so there is also a negatively charged
particle called an
electron.
To maintain the zero charge, the number of electrons and protons
must be the same. If protons and electrons are not equal, the atom
will have a charge and be called an
ion.
-
the
neutron has a mass of 1 amu. However, it does not have a charge. Therefore
the sum of the protons and neutrons is called the
mass
number (
A). It is possible for atoms to have the same
number of protons but different numbers of neutrons; these atoms
are called
isotopes.
-
The
average
atomic mass takes into account not only all the naturally
occurring isotopes, but also the relative abundance of each. The
average atomic mass is also listed in the periodic table.
-
A more general term for light is
electromagnetic
radiation, since light is a form of energy that has both
electric and magnetic properties. Electromagnetic radiation also
has
particle-wave
duality, properties of both particles and waves.
-
Many periodic tables, including
the one on the inside front cover of the text, have a staircase-like
division that runs between aluminum (Al) and silicon (Si) and continues
between germanium (Ge) and arsenic (As) to the bottom of the table.
This "staircase" provides a useful way to categorize elements. Those
to the left of the staircase are
metals.
Properties of metals include a metallic luster (they are shiny),
malleability (it dents), and ductility (they can be pulled into
a wire).
-
Molecular
compounds are usually combinations of nonmetal atoms that
are chemically bonded into a group, called a
molecule.
Ionic compounds are held together by oppositely charged atoms or groups of atoms
called ions.
-
Ephesians 2 - Passage Lookup - New International Version - BibleGateway.com on 2009-11-22
-
4But because of his great love for us, God, who is rich in mercy, 5made us alive with Christ even when we were dead in transgressions—it is by grace you have been saved.
-
1As for you, you were dead in your transgressions and sins, 2in which you used to live when you followed the ways of this world and of the ruler of the kingdom of the air, the spirit who is now at work in those who are disobedient.
-
-
8For it is by grace you have been saved, through faith—and this not from yourselves, it is the gift of God— 9not by works, so that no one can boast. 10For we are God's workmanship, created in Christ Jesus to do good works, which God prepared in advance for us to do.
-
3But now in Christ Jesus you who once were far away have been brought near through the blood of Christ.
-
His purpose was to create in himself one new man out of the two, thus making peace, 16and in this one body to reconcile both of them to God through the cross, by which he put to death their hostility. 17He came and preached peace to you who were far away and peace to those who were near. 18For through him we both have access to the Father by one Spirit.
-
19Consequently, you are no longer foreigners and aliens, but fellow citizens with God's people and members of God's household, 20built on the foundation of the apostles and prophets, with Christ Jesus himself as the chief cornerstone.
-
Javanotes 5.1, Section 5.3 -- Programming with Objects on 2009-11-18
-
The
broadest of these is object-oriented analysis and design
which applies an object-oriented methodology to the earliest
stages of program development, during which the overall design of a program is
created. Here, the idea is to identify things in the problem domain that can be
modeled as objects. On another level, object-oriented programming encourages
programmers to produce generalized software components
that can be used in a wide variety of programming projects.
-
Although the focus of object-oriented programming is generally on the design
and implementation of new classes, it's important not to forget that the
designers of Java have already provided a large number of reusable classes.
-
-
A string can be built up from smaller pieces using the + operator,
but this is not very efficient. If str is a String and
ch is a character, then executing the command
"str = str + ch;" involves creating a whole new
string that is a copy of str, with the value of ch appended
onto the end. Copying the string takes some time. Building up a long string
letter by letter would require a surprising amount of processing. The class
StringBuffer makes it possible to be efficient about
building up a long string from a number of smaller pieces. To do this,
you must make an object belonging to the StringBuffer
class. For example:
StringBuffer buffer = new StringBuffer();
-
Like a String, a StringBuffer
contains a sequence of characters.
However, it is possible to add new characters onto the end of a
StringBuffer without making a copy of the data that it already
contains. If
x is a value of any type and buffer is the variable
defined above, then the command buffer.append(x)
will add x, converted into a string representation, onto the end of
the data that was already in the buffer. This command actually modifies the
buffer, rather than making a copy, and that can be done efficiently. A long
string can be built up in a StringBuffer using a sequence of
append() commands. When the string is complete, the function
buffer.toString() will return a copy of the string in the buffer as an
ordinary value of type String. The StringBuffer
class is in the standard package java.lang, so you can use its simple name without
importing it.
-
System.out.println( new Date() );
Of course, to use the Date class in this way, you must make it
available by importing it with one of the statements
"import java.util.Date;" or "import java.util.*;"
at the beginning of your program. (See Subsection 4.5.3
for a discussion of packages and import.)
-
If randGen is created
with the command:
Random randGen = new Random();
and if N is a positive integer, then randGen.nextInt(N)
generates a random integer in the range from 0 to N-1. For
example, this makes it a little easier to roll a pair of dice. Instead of
saying "die1 = (int)(6*Math.random())+1;", one can say
"die1 = randGen.nextInt(6)+1;". (S
-
5.3.2 Wrapper Classes and Autoboxing
-
Javanotes 5.1, Section 4.5 -- APIs, Packages, and Javadoc on 2009-11-18
-
-
The Java programming language is supplemented by a large, standard API.
You've seen part of this API already, in the form of mathematical subroutines
such as Math.sqrt(), the String data type and its associated
routines, and the System.out.print() routines. The standard Java API
includes routines for working with graphical user interfaces, for network
communication, for reading and writing files, and more. It's tempting to think
of these routines as being built into the Java language, but they are
technically subroutines that have been written and made available for use in
Java programs.
Java is platform-independent. That is, the same program can run on platforms
as diverse as Macintosh, Windows, Linux, and others. The same Java API must work
on all these platforms. But notice that it is the interface
that is platform-independent; the implementation varies from
one platform to another.
-
-
4.5.2 Java's Standard Packages
-
You can have even higher
levels of grouping, since packages can also contain other packages. In fact,
the entire standard Java API is implemented in several packages. One of these,
which is named "java", contains several non-GUI packages as well as the
original AWT graphics user interface classes. Another package,
"javax", was added in Java version 1.2 and contains the classes used
by the Swing graphical user interface and other additions to the API.
-
A package can contain both classes and other packages. A package that is
contained in another package is sometimes called a "sub-package."
-
The java package includes several other sub-packages, such as
java.io, which provides facilities for input/output,
java.net, which deals with network communication, and
java.util, which provides a variety of "utility" classes. The
most basic package is called java.lang. This package contains
fundamental classes such as String, Math,
Integer, and Double.
-
You could say:
java.awt.Color rectColor;
This is just an ordinary variable declaration of the form
"type-name variable-name;".
Of course, using the full name of every class can get tiresome, so Java makes it
possible to avoid using the full name of a class by importing
the class. If you put
import java.awt.Color;
at the beginning of a Java source code file, then, in the rest of the file,
you can abbreviate the full name java.awt.Color to just the simple name of
the class, Color.
-
Note that the import line comes at the start of
a file and is not inside any class. Although it is sometimes referred to
as a statement, it is more properly called an import directive
since it is not a statement in the usual sense.
-
Even an expert programmer won't be familiar with the entire API,
or even a majority of it. In this book, you'll only encounter
several dozen classes, and those will be sufficient for writing a
wide variety of programs.
-
4.5.3 Using Classes from Packages
-
There is a shortcut for importing all
the classes from a given package. You can import all the classes from
java.awt by saying
import java.awt.*;
The "*" is a wildcard that matches every class in the package.
(However, it does not match sub-packages; you cannot import the entire
contents of all the sub-packages of the java package by saying
import java.*.)
-
I often
use wildcards to import all the classes from the most relevant packages, and use
individual imports when I am using just one or two classes from a given package.
In fact, any Java program that uses a graphical user interface is likely to
use many classes from the java.awt and java.swing packages
as well as from another package named java.awt.event,
and I usually begin such programs with
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-
It's possible
for two classes that are in different packages to have the same name. For
example, both the java.awt package and the java.util package
contain classes named List. If you import both java.awt.* and
java.util.*, the simple name List will be ambiguous. If you
try to declare a variable of type List, you will get a compiler error
message about an ambiguous class name. The solution is simple: Use the full
name of the class, either java.awt.List or java.util.List.
Another solution, of course, is to use import to import the individual classes you
need, instead of importing entire packages.)
-
Because the package java.lang is so fundamental, all the classes in
java.lang are automatically imported into every
program. It's as if every program began with the statement "import
java.lang.*;". This is why we have been able to use the class name
String instead of java.lang.String, and Math.sqrt()
instead of java.lang.Math.sqrt(). It would still, however, be
perfectly legal to use the longer forms of the names.
-
.
You might wonder where the standard classes are actually located. Again, that can
depend to some extent on the version of Java that you are using, but in the standard
Java 5.0, they are stored in jar files in a subdirectory of the main Java installation
directory. A jar (or "Java archive") file is a single file that can contain many classes.
Most of the standard classes can be found in a jar file named classes.jar.
In fact, Java programs are generally distributed in the form of jar files, instead of as
individual class files.
-
Macintosh Toolbox - Wikipedia, the free encyclopedia on 2009-11-17
-
Legacy
In Mac OS X, the Toolbox is not used at all, though the Classic environment loads the Toolbox ROM file into its virtual machine. Much of the Toolbox was restructured and implemented as part of Apple's Carbon programming API, allowing programmers familiar with the Toolbox to port their program code more easily to Mac OS X.
-
Javanotes 5.1, Section 5.2 -- Constructors and Object Initialization on 2009-11-17
-
Object types in Java are very different from the
primitive types. Simply declaring a variable whose type is given as a class
does not automatically create an object of that class. Objects must be
explicitly constructed. For the computer, the
process of constructing an object means, first, finding some unused memory in
the heap that can be used to hold the object and, second, filling in the
object's instance variables.
-
5.2.1 Initializing Instance Variables
-
-
public int die1 = 3; // Number showing on the first die.
public int die2 = 4; // Number showing on the second die.
-
It's important to understand when
and how this happens. There can be many PairOfDice objects. Each time
one is created, it gets its own instance variables, and the assignments
"die1 = 3" and "die2 = 4" are executed to fill in the values
of those variables.
-
For initialization of static member variables, of course, the situation
is quite different. There is only one copy of a static variable, and
initialization of that variable is executed just once, when the class is first
loaded.
-
If you don't provide any initial value for an instance variable, a default
initial value is provided automatically. Instance variables of numerical type
(int, double, etc.) are automatically initialized to zero if
you provide no other values; boolean variables are initialized to
false; and char variables, to the Unicode character with code
number zero.
-
Part of this expression, "PairOfDice()",
looks like a subroutine call, and that is no accident. It is, in fact, a call
to a special type of subroutine called a constructor.
This might puzzle you, since there is no such
subroutine in the class definition. However, every class has at least one
constructor. If the programmer doesn't write a constructor definition in a
class, then the system will provide a
default constructor for that class.
This default constructor does nothing
beyond the basics: allocate memory and initialize instance variables. If you
want more than that to happen when an object is created, you can include one or
more constructors in the class definition.
-
A constructor does not have any return type
(not even void). The name of the constructor must be the same as the
name of the class in which it is defined. The only modifiers that can be used
on a constructor definition are the access modifiers public,
private, and protected. (In particular, a constructor can't
be declared static.)
-
public PairOfDice(int val1, int val2) {
// Constructor. Creates a pair of dice that
// are initially showing the values val1 and val2.
die1 = val1; // Assign specified values
die2 = val2; // to the instance variables.
-
The constructor is declared as "public PairOfDice(int val1, int
val2) ...", with no return type and with the same name as the name of the
class. This is how the Java compiler recognizes a constructor. The constructor
has two parameters, and values for these parameters must be provided when the
constructor is called. For example, the expression "new PairOfDice(3,4)"
would create a PairOfDice object in which the
values of the instance variables die1 and die2 are initially
3 and 4. Of course, in a program, the value returned by the constructor should
be used in some way, as in
PairOfDice dice; // Declare a variable of type PairOfDice.
dice = new PairOfDice(1,1); // Let dice refer to a new PairOfDice
// object that initially shows 1, 1.
-
In fact, you can have as many different constructors as you want,
as long as their signatures are different, that is, as long as they have
different numbers or types of formal parameters. In the PairOfDice
class,
-
public PairOfDice() {
// Constructor. Rolls the dice, so that they initially
// show some random values.
roll(); // Call the roll() method to roll the dice.
}
public PairOfDice(int val1, int val2) {
// Constructor. Creates a pair of dice that
// are initially showing the values val1 and val2.
die1 = val1; // Assign specified values
die2 = val2; //
-
public class RollTwoPairs {
public static void main(String[] args) {
PairOfDice firstDice; // Refers to the first pair of dice.
firstDice = new PairOfDice();
PairOfDice secondDice; // Refers to the second pair of dice.
secondDice = new PairOfDice();
int countRolls; // Counts how many times the two pairs of
// dice have been rolled.
int total1; // Total showing on first pair of dice.
int total2; // Total showing on second pair of dice.
countRolls = 0;
do { // Roll the two pairs of dice until totals are the same.
firstDice.roll(); // Roll the first pair of dice.
total1 = firstDice.die1 + firstDice.die2; // Get total.
System.out.println("First pair comes up " + total1);
secondDice.roll(); // Roll the second pair of dice.
total2 = secondDice.die1 + secondDice.die2; // Get total.
System.out.println("Second pair comes up " + total2);
countRolls++; // Count this roll.
System.out.println(); // Blank line.
} while (total1 != total2);
System.out.println("It took " + countRolls
+ " rolls until the totals were the same.");
} // end main()
} // end class RollTwoPairs
-
They are more like static member subroutines, but
they are not and cannot be declared to be static. In fact, according
to the Java language specification, they are technically not members of the
class at all! In particular, constructors are not referred to as
"methods."
-
Unlike other subroutines, a constructor can only be called using the
new operator, in an expression that has the form
new class-name ( parameter-list )
where the parameter-list is possibly empty.
-
Of course, if you don't save the reference in a
variable, you won't have any way of referring to the object that was just
created.
-
A constructor call is more complicated than an ordinary subroutine or
function call. It is helpful to understand the exact steps that the computer
goes through to execute a constructor call:
- First, the computer gets a block of unused memory in the heap, large enough
to hold an object of the specified type. - It initializes the instance variables of the object. If the declaration of
an instance variable specifies an initial value, then that value is computed
and stored in the instance variable. Otherwise, the default initial value is
used. - The actual parameters in the constructor, if any, are evaluated, and the
values are assigned to the formal parameters of the constructor. - The statements in the body of the constructor, if any, are executed.
- A reference to the object is returned as the value of the constructor
call.
-
Student(String theName) {
// Constructor for Student objects;
// provides a name for the Student.
name = theName;
}
-
Objects of type
Student can be created with statements such as:
std = new Student("John Smith");
std1 = new Student("Mary Jones");In the original version of this class, the value of name had to be
assigned by a program after it created the object of type Student.
-
Java uses a procedure called garbage collection
to reclaim memory occupied by objects that are no longer accessible to a
program. It is the responsibility of the system, not the programmer, to keep
track of which objects are "garbage." In the above example, it was very easy to
see that the Student object had become garbage. Usually, it's much
harder. If an object has been used for a while, there might be several
references to the object stored in several variables. The object doesn't become
garbage until all those references have been dropped.
-
Javanotes 5.0, Section 5.1 -- Objects, Instance Methods, and Instance Variables on 2009-11-17
-
Object-oriented programming (OOP) represents an
attempt to make programs more closely model the way people think about and deal
with the world.
-
Programming consists of designing a set of objects that somehow model the
problem at hand. Software objects in the program can represent real or abstract
entities in the problem domain. This is supposed to make the design of the
program more natural and hence easier to get right and easier to
understand.
-
-
In fact, it is
possible to use object-oriented techniques in any programming language.
However, there is a big difference between a language that makes OOP possible
and one that actively supports it. An object-oriented programming language such
as Java includes a number of features that make it very different from a
standard language. In order to make effective use of those features, you have
to "orient" your thinking correctly.
-
I have said that classes "describe" objects, or more exactly that the
non-static portions of classes describe objects. But it's probably not very
clear what this means. The more usual terminology is to say that objects
belong to classes, but this might not be much
clearer. (There is a real shortage of English words to properly distinguish all
the concepts involved. An object certainly doesn't "belong" to a class in the
same way that a member variable "belongs" to a class.)
-
Objects are created and destroyed as the program runs, and there
can be many objects with the same structure, if they are created using the same
class.
-
For example, the following class could be used to store information
about the person who is using the program:
class UserData {
static String name;
static int age;
}
-
Now, consider a similar class that includes non-static
variables:
class PlayerData {
String name;
int age;
}In this case, there is no such variable as PlayerData.name or
PlayerData.age, since name and age are not static
members of PlayerData. So, there is nothing much in the class at all -- except
the potential to create objects.
-
An object that belongs to a class is said to be an instance
of that class. The variables that the object contains
are called instance variables. The subroutines
that the object contains are called instance methods.
(Recall that in the context of object-oriented programming,
method is a synonym for "subroutine". From now on, since we are doing
object-oriented programming, I will prefer the term "method.") For example, if the
PlayerData class, as defined above, is used to create an object, then
that object is an instance of the PlayerData class, and name
and age are instance variables in the object. It is important to
remember that the class of an object determines the types of
the instance variables; however, the actual data is contained inside the
individual objects, not the class. Thus, each object has its own set of
data.
-
As you can see, the static and the non-static portions of a class are very
different things and serve very different purposes. Many classes contain only
static members, or only non-static. However, it is possible to mix static and
non-static members in a single class, and we'll see a few examples later in
this chapter where it is reasonable to do so.
-
By the way, static member
variables and static member subroutines in a class are sometimes called
class variables and class methods,
since they belong to the class itself, rather than to instances
of that class.
-
public class Student {
public String name; // Student's name.
public double test1, test2, test3; // Grades on three tests.
public double getAverage() { // compute average test grade
return (test1 + test2 + test3) / 3;
}
} // end of class Student
-
None of the members of this class are declared to be static, so the
class exists only for creating objects. This class definition says that any
object that is an instance of the Student class will include instance
variables named name, test1, test2, and
test3, and it will include an instance method named
getAverage(). The names and tests in different objects will generally
have different values. When called for a particular student, the method
getAverage() will compute an average using that
student's test grades. Different students can have different averages.
(Again, this is what it means to say that an instance method belongs to an
individual object, not to the class.)
-
In Java, no variable can ever hold an object.
A variable can only hold a reference to an object.
-
n a program, objects are created using an operator called new, which
creates an object and returns a reference to that object. For example, assuming
that std is a variable of type Student, declared as above,
the assignment statement
std = new Student();
-
It is certainly not at all true to say that the
object is "stored in the variable std." The proper terminology is that
"the variable std refers to the object,"
and I will try to stick to that terminology as much as possible.
-
It is possible for a variable like std, whose type is given by a
class, to refer to no object at all. We say in this case that std
holds a null reference. The null reference is
written in Java as "null". You can store a null reference in the
variable std by saying
std = null;
and you could test whether the value of std is null by testing
if (std == null) . . .
-
Student std, std1, // Declare four variables of
std2, std3; // type Student.
std = new Student(); // Create a new object belonging
// to the class Student, and
// store a reference to that
// object in the variable std.
std1 = new Student(); // Create a second Student object
// and store a reference to
// it in the variable std1.
std2 = std1; // Copy the reference value in std1
// into the variable std2.
std3 = null; // Store a null reference in the
// variable std3.
std.name = "John Smith"; // Set values of some instance variables.
std1.name = "Mary Jones";
// (Other instance variables have default
// initial values of zero.
-
When one object variable is assigned
to another, only a reference is copied.
The object referred to is not copied.
-
When the assignment "std2 = std1;" was executed, no new object was
created. Instead, std2 was set to refer to the very same object that
std1 refers to. This has some consequences that might be surprising.
For example, std1.name and std2.name are two different names for the
same variable, namely the instance variable in the object that both
std1 and std2 refer to. After the string "Mary
Jones" is assigned to the variable std1.name, it is also
true that the value of std2.name is "Mary Jones".
There is a potential for a lot of confusion here, but you can help protect
yourself from it if you keep telling yourself, "The object is not in the
variable. The variable just holds a pointer to the object."
-
When
you make a test "if (std1 == std2)", you are testing whether the
values stored in std1 and std2 are the same. But the values
are references to objects, not objects. So, you are testing whether
std1 and std2 refer to the same object, that is, whether they
point to the same location in memory. This is fine, if its what you want to do.
But sometimes, what you want to check is whether the instance variables in the
objects have the same values. To do that, you would need to ask whether
"std1.test1 == std2.test1 && std1.test2 == std2.test2 &&
std1.test3 == std2.test3 && std1.name.equals(std2.name)".
-
When writing new classes, it's a good idea to pay attention to the issue
of access control. Recall that making a member of a class public
makes it accessible from anywhere, including from other classes. On the
other hand, a private member can only be used in the class
where it is defined.
-
A variable of type String can only hold a
reference to a string, not the string itself. It could also hold the value
null, meaning that it does not refer to any string at all. This
explains why using the == operator to test strings for equality is not
a good idea.
-
The function greeting.equals("Hello") tests whether
greeting and "Hello" contain the same characters, which is
almost certainly the question you want to ask. The expression
greeting == "Hello" tests whether greeting
and "Hello" contain the same characters stored in the same memory location.
-
Suppose that a variable that refers to an object is declared to be
final. This means that the value stored in the variable can never be
changed, once the variable has been initialized. The value stored in the
variable is a reference to the object. So the variable will continue to refer
to the same object as long as the variable exists. However, this does not
prevent the data in the object from changing. The variable is
final, not the object. It's perfectly legal to say
final Student stu = new Student();
stu.name = "John Doe"; // Change data in the object;
// The value stored in stu is not changed!
// It still refers to the same object.
-
The value of obj is assigned to a formal parameter in
the subroutine, and the subroutine is executed. The subroutine has no power to
change the value stored in the variable, obj. It only has a copy of
that value.
-
void dontChange(int z) { void change(Student s) {
z = 42; s.name = "Fred";
} }
The lines: The lines:
x = 17; stu.name = "Jane";
dontChange(x); change(stu);
System.out.println(x); System.out.println(stu.name);
output the value 17. output the value "Fred".
The value of x is not The value of stu is not
changed by the subroutine, changed, but stu.name is.
which is equivalent to This is equivalent to
z = x; s = stu;
z = 42; s.name = "Fred";
-
In the opinion of many programmers, almost all member variables should
be declared private.
-
accessor method that returns the
value of the variable. For example, if your class contains a private
member variable, title, of type String, you
can provide a method
public String getTitle() {
return title;
}
-
Because of this naming convention, accessor methods are more often referred to
as getter methods. A getter method provides "read access" to
a variable.
-
That is, you might want to make it possible for other classes to specify a new value
for the variable. This is done with a setter method. (If you don't
like simple, Anglo-Saxon words, you can use the fancier term mutator method.)
The name of a setter method should consist of "set" followed by a capitalized copy of
the variable's name, and it should have a parameter with the same type as the
variable. A setter method for the variable title could be written
public void setTitle( String newTitle ) {
title = newTitle;
}
-
public String getTitle() {
titleAccessCount++; // Increment member variable titleAccessCount.
return title;
}
-
public void setTitle( String newTitle ) {
if ( newTitle == null ) // Don't allow null strings as titles!
title = "(Untitled)"; // Use an appropriate default value instead.
else
title = newTitle;
}
-
A couple of final notes: Some advanced aspects of Java rely on the
naming convention for getter and setter methods, so it's a good idea to
follow the convention rigorously. And though I've been talking about using
getter and setter methods for a variable, you can define get and set
methods even if there is no variable. A getter and/or setter method defines
a property of the class, that might or might not correspond
to a variable. For example, if a class includes a public void
instance method with signature setValue(double), then the class
has a "property" named value of type double, and
it has this property whether or not the class has a member variable
named value.
-
Random Variables on 2009-11-13
-
A discrete random variable is one which may take on only
a countable number of distinct values such as 0,1,2,3,4,........
Discrete random variables are usually (but not necessarily) counts.
If a random variable can take only a finite number of distinct values,
then it must be discrete. Examples of discrete random variables include
the number of children in a family, the Friday night attendance at a
cinema, the number of patients in a doctor's surgery, the number of
defective light bulbs in a box of ten.
-
Google Docs on 2009-11-10
-
Equation editorInsert and edit mathematical equations and symbols in documents.
Learn more
-
Mozilla Firefox Start Page on 2009-11-09
Groups
William hummel havn't joined any group yet.