2-20100907 - Introduction to OO Program Design Software...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to OO Program Design Software College of SCU Instructor: Shu Li Email: shuli@scu.edu.cn
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Unit 1.1 Java Applications 1.1.3 Beginning with the Java API 1.1.4 Console I/O
Background image of page 2
3 Unit 1.1 Java Applications 1.1.3 Beginning with the Java API 1.1.4 Console I/O
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Java API API stands for Application Programming Interface( o o ). Java API o Java*L ) J ) e m@ Most programs use both features from the Java API and essential language features. http://java.sun.com/j2se/1.5.0/docs/api/
Background image of page 4
5 Package The classes in the Java API are grouped into packages. Java f ”s ] ]E ] ] l + P {4 ) + . A package is simply a collection of related classes java.awt java.net The fully qualified name of a class that is part of a package is the package name and the class name separated by a dot. java.awt.Color
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 import Statement ) java.lang[4 ) i *L ) T W c import ) * L ) T W e W N .*” o , o import java.awt.Color; import java.awt.*; Classes java.lang.* are automatically imported
Background image of page 6
7 Example public class test { public static void main(String[] args) { try { FileWriter fw = new FileWriter("hello.txt"); String h = "Hello"; String w = "World"; fw.write(h+ " " + w); fw.close (); } catch (IOException e) { System.out.println("Error writing to file:" + e); } } } Qualified  names Simple  name
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 The java.lang.String Class (1) Java*L WDT W c String String ) String(). Constructs a new String object that represents an empty character sequence. String(char[] value). Constructs a new String object that represents the sequence of characters contained in the character array. String(String original). Constructs a new String object that represents the same sequence of characters as the argument. int size(). Obtains the number of characters in the String. char charAt(int index). Returns the character at the specified index.
Background image of page 8
9 The java.lang.String Class (2) boolean equals(Object anObject). Returns true if the specified Object represents a String with the same sequence of characters. int indexOf(int ch). Returns the index of the first occurrence of the character. int indexOf(String str). Returns the index of the first occurrence of the String. boolean startsWith(String prefix). Checks if the String has the specified prefix.
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/12/2011 for the course ECON 101 taught by Professor Professor during the Spring '10 term at Cisco Junior College.

Page1 / 34

2-20100907 - Introduction to OO Program Design Software...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online