Basic Java Language: Difference between revisions
wikademia>Cremisis13 |
wikademia>Cremisis13 |
||
| Line 200: | Line 200: | ||
Note that this won't work for two number values: | Note that this won't work for two number values: | ||
<code>System.out.println(54 + 32)</code>. It would mistake it for the adding operator for values. For strings, the operator is different. So you would have to do: <code>System.out.println(54+""+32)</code> | <code>System.out.println(54 + 32)</code>. It would mistake it for the adding operator for values. For strings, the operator is different. So you would have to do: <code>System.out.println(54+""+32)</code> | ||
Now you can do calculations and print the result! For example, say you want to print 6*6*6*6. Here is the code: | |||
<pre> | |||
public class Multiplying | |||
{ | |||
public static void main(String args[]) | |||
{ | |||
int a = 6; | |||
int b = a*a*a*a; | |||
System.out.println(b + ""); | |||
} | |||
} | |||
</pre> | |||
=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 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 | ||