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:
Instance variables – variables with unique values.
Ex. int wheels=4;
Class variables – variables with fixed value.
Ex. static in numSteeringWheel =1;
Local variables – can only be accessed inside a method block when placed inside it.
Ex. public void accelerate(){
int currentSpeed =20;
}
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:
Post a Comment