{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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: [email protected]
Image of page 1

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

View Full Document Right Arrow Icon
2 Unit 1.1 Java Applications 1.1.3 Beginning with the Java API 1.1.4 Console I/O
Image of page 2
3 Unit 1.1 Java Applications 1.1.3 Beginning with the Java API 1.1.4 Console I/O
Image of page 3

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

View Full Document Right Arrow Icon
4 Java API API stands for Application Programming Interface( o o ). Java API o Java*L ) J ) e [email protected] Most programs use both features from the Java API and essential language features. http://java.sun.com/j2se/1.5.0/docs/api/
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 {4 java.awt {4 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
Image of page 5

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

View Full Document Right 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
Image of page 6
7 Example import java.lang.String; import java.io.FileWriter; import java.io.IOException; 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
Image of page 7

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

View Full Document Right 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.
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.
Image of page 9

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

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

{[ snackBarMessage ]}