-- String is a character array terminated by a Null character. String WOW = "Java is great"; String inst[ ] = {"you can learn", "about", "string"}; 1. You may not change an array of character if it's used to make a string. char C_array[ ] = {'W', 'O', 'W' }; String S = new String(C_array); C_array[0] = 'b'; // illegal in Java 2. '+' = Concatenate two or more strings. '+' = appends one string to another string. String Prog = "the professor is"; String adj[ ] = {"nuts", "dumb", "boring"}; String sent = Professor + adj[0]; System.Out.println("String Output: " + Professor + adj[0] + adj[1] + adj[2]);
-- vector can hold any combination of objects.
Syntax:
Example 1: MenuBar menuBar= new MenuBar(); // Extended from Vector SetmenuBar(menuBar); Menu Grating_menu = new Menu("Objects"); menuBar.add(Grating_menu); Grating_menu.add(new MenuItem("Grating")); Example 2: ObjectMoveChoice = new Choice(); // Extended from Vector ObjectMoveChoice.addItem("Object Move"); ObjectMoveChoice.addItem("Camera"); add(ObjectMoveChoice); // building a frame class Example 3: public void create_geometry() { drawnShapes = new Vector(); drawnShapes.addElement(grating.targetline[ ]); ..... } void printObject() { Shape S; int number_of_shapes = drawnShapes.size(); for (int i = 0; i <number_of_shapes; i++) { S = (Shape)drawnShapes.elementAt(i); S.print( ); S.move(loc); // move drawnShape object by Location // store back to the same position in Vector drawnShapes.setElementAt(S, i); } }
-- Exceptions handle special run-time error condition.
Syntax:
Example 1:
Example 2:
1. String object can not be modified after it's created. a. True. b. False. 2. Vector class defined to model two-dimensional geometic objects. a. True. b. False. 3. Exceptions are always thrown with the Java "throw" statement. a. True. b. False.