Best Blogger Tips

Wednesday 19 June 2013

Static block in Java

0 comments

Static block

Static blocks in Java are initialize before any objects.They can access only static data types that are declared global or are instance variables. But can declare local variables of non-static within their scope.

Example


public class StaticDemonstration {

 static int a;
 static{
  System.out.println("Hello Static");
  a=10;
 int b = 10;
 System.out.println(a==b ? "Right":"Wrong");
 }
 
 public static void main(String[] args) {
 //No Objects
 }

}

Output

Hello static
Right

Tuesday 18 June 2013

Easy Use of switch in Java!

0 comments

Switch

Switch is used as an alternative of if else series of statements. It is more efficient and easy to use than if else if ladder.

Syntax

Switch value{body.. }

Test application

I am going to create a test application in Java using switch that will allow the user to enter any integer numbers from 0 to 10 and the program will produce output in alphabets against any number entered.
import java.util.Scanner;


public class SwitchDemo {

 
 public static void main(String arg[]) {
  
  
    
  System.out.println("Enter the Number to convert " +
    "in alphabets");
  Scanner in = new Scanner(System.in);
  int a;
  do{
   a = in.nextInt();
  
  
   switch(a){
   case 0:
    System.out.println("Zero");
    break;
   case 1:
    System.out.println("One");
    break;
   case 2:
    System.out.println("two");
    break;
   case 3:
    System.out.println("Three");
    break;
   case 4:
    System.out.println("Four");
    break;
   case 5:
    System.out.println("Five");
    break;
   case 6:
    System.out.println("Six");
    break;
   case 7:
    System.out.println("Seven");
    break;
   case 8:
    System.out.println("Eight");
    break;
   case 9:
    System.out.println("Nine");
    break;
   case 10:
    System.out.println("Ten");
    break; 
   default:
    System.out.println("Wrong input");
    break;
   }
  }while(a<=10); 
    
   
   
  }
  
 }


Use of right shift and left shift operator in Java!

0 comments

Left Shift "<<"

The left shift "<<" shifts the highest order bit to the right for number of times the user specified.

Syntax

value << position 
The value is increased with the double effect according to the value of the position specified.

Example

int value = 10;
int position = 2;

int result = value << position;
So the final value that will be stored in the result variable will be 40.(10,20,40)

Right shift ">>"

The right shift ">>" shifts the lowest order bit to the left for number of times the user specified.

Syntax

value >> position 
The value is decrease with the double effect according to the value of the position specified.

Example

int value = 10;
int position = 2;

int result = value >> position;
So the final value that will be stored in the result variable will be 2.(10,5,2.5(2))

Saturday 15 June 2013

Creating a beautiful login web page.

0 comments
Creating a beautiful login web page.

Screen Shot

login page

Monday 3 June 2013

KL02 Chip, A miniature Computer!

0 comments
KL02 Chip, A miniature Computer! KL02 Chip An invention of two mm chip is just an effort to make available the computer power everywhere. This is what we actually called ubiquitous.
If the internet has to reach everywhere- say from the medicines we take to the clothes we wear, keys we use for locking or unlocking, remote for switching on or off, toaster for toasting slices then computer will definitely need to get a whole lot of tiny. This is really a promising start by the folks to introduce a 2 millimeters square microchip.
KL02 is an ant –ant sized miniature silicon chip unfolded by FreeScale, It is shorter from both the sides like the ants but packs a central unit, a memory unit and many other components.

Saturday 1 June 2013

An in-depth exploration of Samsung Galaxy S4: A real world guesstimation!

0 comments
An in-depth exploration of Samsung Galaxy S4: A real world guesstimation! There are lot of appealing qualities of Galaxy S4 and a lot of astound flaws. Is it a perfect phone for your requirements or not???
There are many things in this world that do not need any introduction. I would say Samsung Galaxy S4 is not one amongst those. Definitely, “Galaxy S series” has practically become a menage name. And sure definitely, you have possibly probably heard all types of hype about the newest Samsung model. But you will have to trust me; there are more to the galaxy s4 than that meets the eye. I am in the use of Galaxy s4 for about three weeks and I say with my complete nerve control that while this smart phone has its share of unique,
 

| Bloggers Broadcast © 2010. All Rights Reserved | Back To Top |

Your Text Link Here