Understanding References, Packages, and Javadoc in Java: A Comprehensive Guide, Slides of Java Programming

An in-depth exploration of java references, packages, javadoc, and their significance in java programming. Topics covered include managing references, copying references, leaking references, debugging, and packages with javadoc and importing. Understand how to master references, avoid memory leaks, and effectively use packages and javadoc.

Typology: Slides

2012/2013

Uploaded on 04/23/2013

sarmistha
sarmistha 🇮🇳

3.8

(22)

112 documents

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
References, packages
and javadoc
“pointers” are
“references”
memory
locations
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Understanding References, Packages, and Javadoc in Java: A Comprehensive Guide and more Slides Java Programming in PDF only on Docsity!

References, packages

and javadoc

“pointers” are “references”

memory locations Docsity.com

Announcements

HW 2 solutions on moodle

Matryoshka doll

(See: MemoryEater.java)

References - null

If a variable references null, then you will crash your program if you use the reference

For example:

String x = null; int y = x.length();

References - leaking

If data is private, then it can only be changed through methods, right?

Classes are stored as references... If you give out its reference, then it can be changed (See: NextInLine.java and Counter.java) Docsity.com

References - leaking

If you want to not leak your private classes, make a copy of that class and give that out instead

This would not have been a problem if couter did not have a setCounter(x) method

(Remember if you cannot change the data, the class is called immutable, like String)

Packages

Java files in a packages are grouped together and you can see and use classes in the same package

javadoc and importing

javadoc gives descriptions of how classes, methods, etc. should be used

(See: SampleJavadoc.java)

To import other packages and/or JARs (other people's Java code) in NetBeans, simply right click on the “Libraries” in the package