Basic Java Language: Difference between revisions
wikademia>Cremisis13 |
wikademia>Cremisis13 m →Comments: Minor Edit - REmoval of -s |
||
| Line 166: | Line 166: | ||
You can't create two variables with the same identifier, all identifiers must be unique. You also can't use an identifier that is a Java keyword. Here is a list of all the [http://en.wikipedia.org/wiki/Java_keywords Java Keywords]. [[Flashcards for Java keywords]] provides some assistance in memorizing the concepts behind specific keywords. | You can't create two variables with the same identifier, all identifiers must be unique. You also can't use an identifier that is a Java keyword. Here is a list of all the [http://en.wikipedia.org/wiki/Java_keywords Java Keywords]. [[Flashcards for Java keywords]] provides some assistance in memorizing the concepts behind specific keywords. | ||
=Comments= | =Comments= | ||
Comments are notes that the developer can insert into their code. This allows the developer to keep track of their code and helps when developers are collaborating on a project. It is good to write a summary of the following code at the beginning of your methods, classes, etc. The Java compiler completely ignores comments, so you can say anything in them | |||
Comments are written using two forward slashes | |||
<pre>//This is a comment</pre> | |||
Comments can be written at the end of a line | |||
<pre>System.out.println("I love comments"); //This is also a comment</pre> | |||
Comments can also be written on multiple lines by starting with '''/*''' and ending with'''*/'''. | |||
<pre>/* Comment 1 | |||
Comment 2 | |||
Comment 3 */</pre> | |||
Sun recommends the above form be reserved for information intended for automatic JavaDoc documentation. | |||
=Compiling and Running your program= | =Compiling and Running your program= | ||