Java101
Java101
CPRG304 – Object-Oriented
Programming III
• Various editions
• Java SE
• Java EE
• Java ME
• Java Card
Eclipse and the JDK
• Dedicated IDE mostly for Java, written in Java
• Free and open-sourced
• Rapid release cycles of 4 months
• https://www.eclipse.org/downloads/packages/
• Do NOT download the latest release! (unless your intention is to test
that release)
• Newest releases of anything == full of bugs!
• No destructors in Java
• Similar concept are finalizers but use is discouraged*
• Finalizer of base class are not automatically called
Methods
• Parameters are always passed by copy
• No support for passed by reference (i.e. no in, ref, out)
• Can only return one value
• Return type in method signature is not void, use return statement
• Similar structure:
• Test class (fixture)
• Test method
• No TestCase attribute, must be separate test methods
• setup() and teardown()
• setUpBeforeClass(), tearDownAfterClass()
• Assertions
• Can be ran in eclipse just like a Java program! (test runner)
Streams and Serialization
• Streams are used for I/O to read and write from files,
storage and over networks
• Predefined Java streams: do not need to be instantiated
• Created by the JVM on initialization on the platform it’s running on
• Byte-oriented vs Character-oriented streams
• Chaining and buffering
• File I/O