JAVA שיעור #5 
1. javadoc   /**  ...  */
     Tag          Description             Applies to  
    @see        Associated class name   Class, method, or variable
    @author     Author name             Class
    @version    Version string          Class
    @param      Parameter name,description  Method
    @return     Description of return value Method
    @exception  Exception name,description  Method
 @author John Smith             
 @param number   The integer to print out.
 @version 1.00, 19 Dec 1996
 javadoc SortPgm.java --> Sortpgm.html
 URL


Class SortPgm

java.lang.Object | +----SortPgm ---------------------------------------------------------------------------- public class SortPgm extends Object SortPgm reads a list of integers from the standard input, sorts them, and outputs the sorted list. SortPgm() -------------------------------------------------------------------------------------------------- main(String[]) SortPgm public SortPgm() main public static void main(String args[]) 2. package import java.net.URL; import java.util.Vector; import java.util.*; bitset, hashtable, dictionary, stack, vector Date StringTokenizer Properties Observer Observable Random Java.util.BitSet java.util.Hashtable 3. Vector smallQ = new Vector(20,3), largeQ = new Vector(), medQ = new Vector(1100); v = new Vector(); capacityIncrement elementCount elementData public void addElement(Object) public int capacity() public int size() public boolean contains(Object) public int lastIndexOf(Object) public Object firstElement() public void removeElements() int i; v.addElement(u) User lastUser = v.lastElement(); User lastUser = (User) v.lastElement(); v.addElement(i) v.addElement(new Integer(i)) Integer i = (Integer) v.lastElement() int in = ((Integer) v.lastElement()).intValue() vec1.addElement (c) ; vec2.addElement (u) ; vec3.addElement (l) ; Object o = v.lastElement(); if (o instanceof User) { // code to process User objects } if (o instanceof Link) { // code to process Link objects } 4. class LinkingInfo { String computer; Vector linkedComputers; public LinkingInfo(String computerName, int size) { linkedComputers = new Vector(size,10); computer = computerName; } public LinkingInfo(String computerName) { this(computerName, 50); } public int noOfLinkedComputers() { return linkedComputers.size(); } public String computerName() { return computer; } public boolean isLinked(String comp1) { return linkedComputers.contains(comp1); } public void addComputer(String comp1) throws ComputerErrorException { if (linkedComputers.contains(comp1)) throw new ComputerErrorException ("Computer already in links"); else linkedComputers.addElement(comp1); } public void removeComputer(String comp1) throws ComputerErrorException { if (!linkedComputers.contains(comp1)) throw new ComputerErrorException ("Computer not in links"); else linkedComputers.removeElement(comp1); } } 5. Hashtable associations = new Hashtable(); associations.size() containsKey(Object key) get(Object key) put(Object key,Object value) 6.Date now=new Date();System.out.println(now); // Wed Feb 14 06:02:30 CST 1997 Date adate = new Date("Dec 19, 1997"); Date bdate = new Date("19 Dec 1997"); If (me.before(you)) //I'm older than you 7. Upcasting: widening (subclass --> superclass) Circle extends Shape Shape s = new Shape(); Circle c = new Circle(); s=c; 8. Downcasting: narrowing (superclass --> subclass) Class Queue { public void insertLast(Shape s) { ... } public Shape getFirst() { ... } public int size() { ... } ... } class Drawcanvas { Queue shapeQ = new Queue(); Static public void main(String args[]) { Circle c = new Circle(0,0,30); ShapeQ.insertLast(c); Rectangle r = new Rect(0,0,50,100); ShapeQ.insertLast(r); ... } } public void ScaleCircles(float factor) { for (int p=0; p