Sunday, May 31, 2009

Java Basics Using Qt Jambi Tutorial

Variables

We've already used variables in our previous examples. Variables are identifiers that store values in your computer memory. There are four types of variables:

  1. Instance variables – variables with unique values.

Ex. int wheels=4;

  1. Class variables – variables with fixed value.

Ex. static in numSteeringWheel =1;

  1. Local variables – can only be accessed inside a method block when placed inside it.

Ex. public void accelerate(){

int currentSpeed =20;

}

  1. Parameters – variables inside method or constructors and exception handlers.

Ex. public static void main(String[] args) //args is the parameter with a String type of method main.

to be continued...

No comments: