Introduction to Java Programming Lecture 15 Objects and Classes

Download Introduction to Java Programming Lecture 15 Objects and Classes

Post on 20-Dec-2015

214 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

<ul><li> Slide 1 </li> <li> Introduction to Java Programming Lecture 15 Objects and Classes </li> <li> Slide 2 </li> <li> Using Classes from the Java Library Java classes java.lang Classes Classes methods, : System, String, Math, Integer, Double, import package classes , : java.util.Scanner java.io.BufferedReader java.io.InputStreamReader java.io.IOException javax.swing.JOptionPane </li> <li> Slide 3 </li> <li> String charAt() method String length() method ( ) String toUpperCase() toLowerCase() 2 method method toUpperCase() toLowerCase() String indexOf() method (Sample3.java)Sample3.java </li> <li> Slide 4 </li> <li> String StringBuffer StringBuffer String StringBuffer method (Sample4.java)Sample4.java </li> <li> Slide 5 </li> <li> Integer Integer Methods : static int parseInt(String s) : static Integer valueOf(String s) : Integer </li> <li> Slide 6 </li> <li> Using JFrame from javax.swing import javax.swing.JFrame; class TestFrame { public static void main(String[] args) { JFrame frame1 = new JFrame(); frame1.setTitle("Window 1"); frame1.setSize(300, 300); frame1.setLocation(200, 100); frame1.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame1.setVisible(true); } </li> <li> Slide 7 </li> <li> class Sample1 { public static void main(String args[]) { Car car1 = new Car(); Car car2; car2 = car1; car2.show(); } // class class Car { int num; double gas; void show() { System.out.println(" " + num + " "); System.out.println(" " + gas + " "); } car1 car2 (Sample6.java)Sample6.java (Sample7.java)Sample7.java </li> <li> Slide 8 </li> <li> null null class Sample { public static void main(String args[]) { Car car1; car1 = new Car(); Car car2; car2 = car1; car1 = null;... } </li> <li> Slide 9 </li> <li> method (See Sample8.java)Sample8.java </li> <li> Slide 10 </li> <li> Array of Objects Car[ ] carArray = new Car[10]; (See Sample9.java)Sample9.java int test[]; test = new int[5]; test[0] = 80; test[1] = 60;... </li> <li> Slide 11 </li> <li> Java API and Core Java classes java.lang Contains core Java classes, such as numeric classes, strings, and objects. This package is implicitly imported to every Java program. java.awt Contains classes for graphics. javax.swing Contains graphical user interface components java.applet Contains classes for supporting applets. </li> <li> Slide 12 </li> <li> java.io Contains classes for input and output streams and files. java.util Contains many utilities, such as date. java.net Contains classes for supporting network communications. Java API and Core Java classes, cont. </li> <li> Slide 13 </li> <li> java.awt.image Contains classes for managing bitmap images. java.awt.peer Platform-specific GUI implementation. Others: java.sql java.rmi Java API and Core Java classes, cont. </li> </ul>