Friday, May 9, 2008

Using Comments

Comments are important to every language. Good programmers place comments on any potentially ambiguous line of code. Others can use these comments to debug any cryptic code; you can even use them if you have return to your function after any length of time.

Comments in Visual J++ are similar to comments in C++, and are easy to implement. There are three types of comments: single line comments, multiple line comments and documentation comments.

Warning 2

Build the project by clicking on Build I build myIntegerTest to build the file. When prompted to create a default project workspace, click yes.

Execute the project by clicking on Build Execute. In the Dialog box that appears, type myInteger in the Class file nam field and click ok to continue. The following shows the DOS that opens with the output displayed

Monday, May 5, 2008

Warning

In the above code, just like in C/C+, the double backslash denotes a single line comment and the /'*I denotes multiline comments. (Please see the next section)

5. Save the text file by clicking on File1 Save. A Save As dialog box appears. Save this file as my IntegerTest.java in the msdev\projects directory on your system.

Sunday, May 4, 2008

Declaring Data Types 3

Notes on your code

Notice in the above code that you are declaring three integer data types: a byte called my Integer1, an int called myInteger2, and a long called myInteger 3. Then, you are using three lines of code, each containing printIn () to print out the values for eachof these variables.

Saturday, May 3, 2008

Declaring Data Types 2

3. Open a new text file in the Developer Studio by clicking on File1 New. On the dialog that appears, specify that you want to open a text file, and a fresh text file window appears, waiting for you to write you code.

4. In the Text Editor window, type your following code down starting with :
Class myIntegerTest {

Friday, May 2, 2008

Declaring Data Types

Let's go ahead and create a project in Visual J++, declaring various integer data types and assigning them values:

1. Make sure that you have Java J++ loaded.

2. If you still have the previous project from Chapter 1 open, you need to close it. Do this by clicking on File1 close workspace.

Thursday, May 1, 2008

Declaring Variable's Type

In Java, you must declare each variable’s type before you actually use them. To declare the variable type, all you have to do is to indicate the type and followed by the name of the variable. We call this process variable declaration. Variables are places where you store information. It is like a piggy bank where you put money in.