Presentation is loading. Please wait.

Presentation is loading. Please wait.

L3. Necessary Java Programming Techniques

Similar presentations


Presentation on theme: "L3. Necessary Java Programming Techniques"— Presentation transcript:

1 L3. Necessary Java Programming Techniques
Java API (Vector) Continue doing ex2 Packages  Java.util import Java.util.*; Classes  Vector Interfaces  Enumeration

2 An example of using class Vector
Run Java applet => VectorTest.html Take a look at source code => VectorTest.java Exercise: 1. Understand and run the program. 2. Add a reverse button and it displays the elements in the vector in a reverse order.

3 Output: Optional exercise:
  Enter lines of input, use quit to end the program.   apple   orange   banana   grape   lemon   quit   Number of lines: 5   Middle line: banana   Lines in reverse order:   Lines in reverse alphabetical order: Optional exercise: Write a java application program that uses Vector class and can output the result as shown in the right.

4 The program outline: import java.io.*; import java.util.*;
public class ReverseLines { public static void main (String[] args) throws IOException { BufferedReader in = new BufferedReader (new InputStreamReader (System.in)); final String STOPPER = "quit"; Vector lines = new Vector(); System.out.println ("Enter lines of input, use " + STOPPER + " to end the program."); // Read in line of input until user enters stopping value. // Put each line of input into the vector. // your source code    // Print the lines in reverse order - step 4 in the handout. // Print the lines in reverse alphabetical order }


Download ppt "L3. Necessary Java Programming Techniques"

Similar presentations


Ads by Google