Thursday, February 9, 2012

Naming Java files

File names must be the same as class names.

For instance, a class called HelloWorld must be saved as HelloWorld.java

Recommended video: Tutorial:: Intro to Java

http://youtu.be/ZIaCURrxU00

Downloads/resources mentioned in this tut:

Java JDK http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u2-download-1377129.html
Java Documentation http://docs.oracle.com/javase/7/docs/api/
Notepad++ http://notepad-plus-plus.org/download/v5.9.8.html

Comments

Commenting your code is important. Comments allow you to provide internal documentation of your code - for yourself and others.

A single line comment is started with //

as in

// This is a comment





A multiline comment is started with /* and ended with */

as in

/* Comment begins here....
.....
....
comment ends here */

Tuesday, January 31, 2012

Remainder

"The Remainder or Modulus Operator in Java" ( http://bit.ly/zOQRrd )

For instance 10 % 3 is 1 because 10 divided by 3 leaves a remainder of 1.

int i = 10;
int j = 3;

System.out.println("i is " + i);
System.out.println("j is " + j);
  
int k = i % j;
System.out.println("i%j is " + k);
 
% javac Remainder.java
% java Remainder
i is 10
j is 3
i%j is 1 

Time

Returns long:
System.currentTimeMillis();

Cast int to double

(double) i

Primitive Data Types

"Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)" ( http://bit.ly/xesQuj )