Saturday, August 11, 2012

JAVA KEYWORDS WITH EXPLANATION



There are near about 50 keywords ( reserved words) in core Java.The tables bellow demonstrate JAVA keywords with description and example and assigned alphabetically.Hope that you will find useful for learning or refreshing your memory......
Please inform me by posting comments if I am wrong...




keyword description example
Abstact used in class and method declaration.
Abstract class:
1) class must be declared with abstract keyword
2) methods in abstract class may or may not be abstract
3)If a class contains at-least one abstract method, the class must be declared as abstract.
4)Abstract methods must not be implemented in abstract class. Methods must be implemented in sub classes
5) An abstract class can not be instantiated, its solo mission is to be subclassed.

abstact class Myclass // abstract class
{
public abstact void do();// is a abstract method
public String getName()
{ }
}
Assert followed by a boolean value
(true or false), or an expression,
 to be evaluated at runtime, that
returns a  boolean value. If the boolean expression evaluates to false, then an AssertionError is thrown.

assert true;
assert 50 == 50;


// this will throw an Assertion Error:
int test = 50;
assert test == 100;

boolean is a data type which stores boolean
value, i.e True or False. It is also used
to declare methods that returns a value
which is also a boolean.
boolean myFlag = true;
breakOne of the control statement to
control the program flow. used to
break the loop of switch statement.
1) Unlabeled Break statement
2) Labeled Break Statement

1) Unlabeled Break statement

for(int num =0; num < 5 ; var++)
{      System.out.println(“Num is : “ + num);

  if(num == 3)
     break;
}


2)Labeled Break Statement

Back:

for(int num1=0; var1 < 10 ; num1++)
{
 for(int num2 = 1; num2 < 10; num2++)
 {             System.out.println(“num1:” + num1 + “, num2:” + num2);
     if(num1 == 5)
break Back;
 }
}
byte8 bit signed 2's complement integerbyte b = -1;
casecase is used in Switch statement
switch ( value/variable to test ) {
case value:    
your code_here;
break;
case value:
your code_here;
break;
default:
value/variable_not_above;
}
catchuse with try block to catching exceptiiontry
{ code here}
catch( exception )
{}


charcharacter type in unicode   char test ="y"
classimplementation of a particular kind
of object which defines instance,
class fields, methods,innner classes,interfaces as well as 
superclasses of class 

class Person {
private String name;
public Person(String myName) {
this.name = myName;
}
public void show() {
System.out.println(name);
}
}

classs Strudent extends Person
{
Pesron p = new Person();
p.show();
}
constis keyword in Java, but till now not used 
continueto skip the rest of the statement
in body of the loop and continue
with the next iteration of the loop
1)Unlabeled Continue
2)labeled Continue 

1)Unlabeled Continue 
for(int num1 =0; num1 < 15 ; num1++)
{
   for(int num2=0 ; num2 <1 5 ; num2++)
 {      if(num2 == 2)
           continue;
  System.out.println( num1 + num2);
 }
}


2) Labeled Continue
Back:
for(int num1 =0; num1 < 5 ; num1++)
{

 for(int num2=0 ; num2 < 5 ; num2++)
  {
       if(var2 == 2)
        continue Back;
 System.out.println( num1 + num2);

   }
}


defaultcan optionally be used in
"Switch case"  labelling a block
of statement which is to be
executed
 see case
douse with while to form "do-while"
loop uses boolean  expression to
execute block of statements

do {
     statement(s)
} while (expression);
double 64-bit double precision IEEE 754  floating-point number double mydouble = 0.05;
elseuse with "if " to form "if else" or "else if" statement tests boolean expression
int score = 79;
        char status;
        if (score >= 90) {
            status= 'A';
        } else if (score >= 80) {
            status = 'B';
        } else if (score >= 70) {
            status = 'C';
        } else if (score >= 60) {
            status = 'D';
        } else {
            status = 'F';
        }
        System.out.println("status = " + grade);
   
enumenumeration is a type whose  field consist of a fixed value of constant. It extends base class called Enum 
public enum Day {
 SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
}




Tuesday, July 31, 2012

NETBEANS IDE 6/7 KEYBOARD SHORTCUTS & CODE TEMPLATES (WINDOWS)



KEYBOARD SHORT-CUTS  & CODE TEMPLATES FOR WINDOWS


The NetBeans IDE has seen one of the popular among IDE's over the past years, particularly with the adaptation of a completely smart,intelligent, slick Java/J2EE  along with different open source appliaction editor. Here are the Keyboard Short-Cuts, Hope that You will like for reference.....

Searching, Finding, and Replacing



KEYACTION                                 
Ctrl-F3 For Search word at insert point
Ctrl-F/H For Find/Replace in file
Ctrl-Shift-PTo Find/replace in projects
Ctrl-R For Rename
Ctrl-U, and SToggle case of selection
Ctrl-U, then LConverting the selection to lowercase
Ctrl-U, then UConverting the selection to uppercase
Alt-Shift-VFormatted Paste
Alt-F7Finding usages
Alt-Shift-UFind usages results
Alt-Shift-HTurning off searched result highlights
F3/Shift-F3Find next/previous in file







NETBEANS IDE Mac OS Keyboard Shortcuts

Mac OS Keyboard Shortcuts NETBEANS 6/7

Here are the shortcuts of NETBEANS 6/7 in MAC OS


Scrolling and Selecting

KEYDESCRIPTION
Cmd-A Selects all text in the file.
Cmd-[
Moves the insertion point to the highlighted matching bracket.
Note that this shortcut only works when the insertion point is
located immediately after the opening bracket.
Ctrl-G Jumps to any specified line.
Cmd-Shift-[
Selects the block between a pair of brackets. Note that this shortcut
only works when the insertion point is located immediately after
either the opening or closing bracket.