Monday, January 21, 2013

Find installed version of Java

Windows
  • Find the 'Run' menu item from the start menu.
  • Open up a command prompt and type:
              java -version




....or you can just visit the Oracle site :)


Thursday, January 17, 2013

! operator (NOT)



The exclamation character is the NOT operator !
The NOT operator is used to evaluate an expression to true or false.


Here's the NOT operator using a simple if statement format:

if (!(condition1)) {
   doSomething();
}

Here's the NOT operator using a if-then-else statement format:



if (!(condition1)) {
   doSomething();
}

else {
   doSomethingElse();
}


The method doSomething() will only execute if the condition in the if statement evaluates to false.

Let's take a look at another, more concrete example:


if (!(respawnRemaining >= 1)) {
   gameOver();
}


The method gameOver() will only execute if respawnRemaining is NOT greater than or equal to 1.

In the following example, we use an if-then-else statement:



if (!(respawnRemaining >= 1)) {
   gameOver();
}

else {
   respawn();
}

If respawnRemaining is NOT greater than or equal to 1, the gameOver method will execute. If it is greater than or equals to 1, the respawn method will execute.



Also see
&& Operator (AND)
|| Operator (OR)


JUnit


"Assert (JUnit API)" ( http://bit.ly/11AK6hX )


Tuesday, January 8, 2013

&& operator (AND)


A double ampersand is the logical AND operator &&

The AND operator is used to evaluate multiple expressions during decision making with if statements.


Here's the AND operator using a simple if statement format:

if (condition1 && condition2) {
   doSomething();
}

Here's the AND operator using a if-then-else statement format:


if (condition1 && condition2) {
   doSomething();
}
else {
   doSomethingElse();
}


The method doSomething() will only execute if both of the conditions in the if statement evaluate to true.

Let's take a look at another, more concrete example:


if (maxDamage > 100 && ammoCount == 0) {
   gameOver();
}


The method gameOver() will only execute if maxDamage is greater than 100 AND ammoCount is equal to 0. If either condition does not evaluate to true, the gameOver() method will not execute.

In the following example, we use an if-then-else statement:


if (maxDamage > 100 && ammoCount == 0) {
   gameOver();
}
else {
   continue();
}


If both conditions are true, the gameOver() method will execute. If both of the conditions are false, the continue() method will execute.

Also see
|| operator (OR)
! Operator (NOT)

|| operator (OR)



A double pipe is the logical OR operator ||

The OR operator is used to evaluate multiple expressions during decision making with if statements.


Here's the OR operator using a simple if statement format:

if (condition1 || condition2) {
   doSomething();
}

Here's the OR operator using a if-then-else statement format:


if (condition1 || condition2) {
   doSomething();
}
else {
   doSomethingElse();
}


The method doSomething() will only execute if one or both of the conditions in the if statement evaluate to true.

Let's take a look at another, more concrete example:


if (maxDamage > 100 || ammoCount == 0) {
   gameOver();
}


The method gameOver() will only execute if either maxDamage is greater than 100 (and or) OR ammoCount is equal to 0. If either condition does not evaluate to true, the gameOver() method will not execute.

In the following example, we use an if-then-else statement:


if (maxDamage > 100 || ammoCount == 0) {
   gameOver();
}
else {
   continue();
}

If either or both of the conditions are true, the gameOver() method will execute. If both of the conditions are false, the continue() method will execute.

Also see
&& Operator (AND)
! Operator (NOT)


Incrementing a number ++


Increment - increase a value.

The increment operator is a double plus ++

The increment operator increases the value to it's left by 1.

Example use with int:

int one = 10;
one ++;

In the first line, an int variable called one is declared and assigned a value of 10.

In the second line, the increment operator is applied to the variable called one to increment it's value.

The result is that the variable called one, now has a value of 11.



Example use with double:

double one = 12.55;
one ++;

In the first line, a double variable called one is declared and assigned a value of 12.55.

In the second line, the increment operator is applied to the variable called one to increment it's value.

The result is that the variable called one, now has a value of 13.55.

Note that where the increment operator is used with the double data type, the increment value is 1 significant number (the number on the left of the floating point is incremented).

See also Decrementing a number

Decrementing a number --


Decrement - decrease a value.

The decrement operator is a double minus --

The decrement operator decreases the value to it's left by 1.

Example use with int:

int one = 10;
one --;

In the first line, an int variable called one is declared and assigned a value of 10.

In the second line, the decrement operator is applied to the variable called one to decrement it's value.

The result is that the variable called one, now has a value of 9.



Example use with double:

double one = 12.55;
one --;

In the first line, a double variable called one is declared and assigned a value of 12.55.

In the second line, the decrement operator is applied to the variable called one to decrement it's value.

The result is that the variable called one, now has a value of 11.55.

Note that where the decrement operator is used with the double data type, the decrement value is 1 significant number (the number on the left of the floating point is decremented).

See also Incrementing a number