T2 Java programming lecture 2

T2 Java programming lecture 2 - BIOC1805Elementsof...

Info icon This preview shows pages 1–17. Sign up to view the full content.

View Full Document Right Arrow Icon
BIOC1805 Elements of Bioinformatics J i Java programming lecture 2 Instructor: Junwen John Wang Department of Biochemistry 11 Feb 09
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Using the Java API http://java.sun.com/javase/6/docs/api/ 11 Feb 09
Image of page 2
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Overview 4
Image of page 4
The Packages panel Choose the package you are interested in Or, choose All Classes Classes in java.lang are automatically imported into every program ‐‐ you don’t have to do it yourself don t have to do it yourself Old snapshots—but the format hasn’t changed 5
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
The Classes panel This panel shows both classes and interfaces We haven’t yet talked about interfaces Note that some classes h i il t have names similar to primitive types ( B l B t Boolean , Byte , Character ) 6
Image of page 6
The links bar Overview is where you start out I d i h d f l ki h d Index is handy for looking up methods Help is the obvious If d ’t lik f h If you don’t like frames, you can choose NO FRAMES Deprecated methods are those that have been replaced by better methods and should not be used 7
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
The main information area General description of the class Field summary Constructor summary M th d Method summary Field detail Constructor detail M h d d il Method detail 8
Image of page 8
How was this documentation produced? All Java documentation was produced by the javadoc program from javadoc (or just doc ) comments in the source code Your doc comments can be used in the same way to produce professional looking documentation Th Interface it i Bl J d th The menu item in BlueJ does the same basic thing as javadoc Like most things in BlueJ, fancy features have been omitted in the interests of simplicity 9
Image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Value of the API V i k l th d Version packages classes methods Java 1.0 8 212 1545 Java 1.1 23 504 3851 Java 1.2 60 1781 15060 Java 1.3 77 2130 17158 Java 1.4 135 2738 ? Java 1.5 and 6 ? ? ? You can only learn a small fraction of these When you learn the kinds of things that are in the API, and learn to find your way around in it, you become a far more effective and efficient programmer A good craftsman knows his/her tools 10
Image of page 10
Java IO (input/output) http://java.sun.com/javase/6/docs/api/ 11 Feb 09
Image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 12
Streams All modern I/O is stream based Stream is flow of data flowing in/out Stream is flow of data, flowing in/out A stream is a connection to a source of data or to a destination for data (sometimes both) An input stream may be associated with the keyboard or a file 13
Image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
How to do I/O import java.io.*; Open the stream U h ( d i b h) Use the stream (read, write, or both) Close the stream 14
Image of page 14
Opening a stream There is data external to your program that you want to get or you want to put data somewhere want to get, or you want to put data somewhere outside your program When you open a stream, you are making a connection to that external place Once the connection is made, you forget about h l l d j h the external place and just use the stream 15
Image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Example of opening a stream A FileReader is a used to connect to a file that
Image of page 16
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.