For the examples in this topic, Word Completion provides visual clues when you're typing the name of String
and System
classes, and creating a new String object. Word Completion is available for any Visual J++ project.
Note The code examples in the following scenario were created with a Visual J++ Console Application project. If you would like to create a Console Application project to complete this scenario, see Creating a Console Application and follow the steps to create and open the project before proceeding.
To select an item from a list provided by the Word Completion feature
main()
method (Class1.java by default) and select View Code from the shortcut menu.Visual J++ opens the Text editor and loads your .java file. The file is now ready for editing.
String
class, type an "S" between the braces of the application's main()
method and leave the cursor to the right of this letter.Tip Notice the red squiggly line drawn under the letter. Since an "S" has no significance within the context of this program, IntelliSense gives a visual clue for the syntax error. For more information about visual editing clues, see Finding Errors with Dynamic Syntax Checking.
Tip You can use the keyboard shortcut, CTRL+SPACE, instead of selecting the Complete Word option on the Edit menu, to display this list box.
Statement Completion now selects StackOverflowError in its list — the first element that starts with an "ST" in the context of this program.
String
" into the statement you're building.Pressing the Tab bar or any other non-alphanumeric key, such as a period or opening parenthesis, places the selected item into a statement at the location of the insertion point.
Tip Instead of typing the letters until Statement Completion finds the element you need, you can use the up and down arrows to highlight your selection.
To select a class name after the new
operator
String
":[String] myStr = new
new
" and Statement Completion automatically displays a list of class names available within the scope of your program.String
" is inserted after "new
".Your statement should look like this:
String myStr = new String
To continue building the statement that displays a line of text, you'll need a constructor for the new String object. See Selecting an Overloaded Method for a procedure that selects a String
constructor with Statement Completion's Parameter Info option.
If you know how to partially spell the name of the class or item, use the following procedure to speed up the process of typing and selecting the correct spelling and capitalization.
To finish typing a word using the Word Completion feature
Statement Completion completes the word, "System
", and inserts it into your code since it is the only item that begins with an "SY". If more than one item starts with these letters, Statement Completion displays a list box.