Posts

Showing posts from July, 2016

Java Basic operators

Java - Basic Operators Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups − Arithmetic Operators Relational Operators Bitwise Operators Logical Operators Assignment Operators Misc Operators The Arithmetic Operators Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra. The following table lists the arithmetic operators − Assume integer variable A holds 10 and variable B holds 20, then − Show Examples Operator Description Example + (Addition) Adds values on either side of the operator. A + B will give 30 - (Subtraction) Subtracts right-hand operand from left-hand operand. A - B will give -10 * (Multiplication) Multiplies values on either side of the operator. A * B will give 200 / (Division) Divides left-hand operand by right-hand operand. B / A will give 2 % (Modulus) Divides left-hand operand by right-hand operand and returns remai...

Java variable types

Java - Variable Types A variable provides us with named storage that our programs can manipulate. Each variable in Java has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable. You must declare all variables before they can be used. Following is the basic form of a variable declaration − data type variable [ = value][, variable [ = value] ...] ; Here  data type  is one of Java's datatypes and  variable  is the name of the variable. To declare more than one variable of the specified type, you can use a comma-separated list. Following are valid examples of variable declaration and initialization in Java − Example int a , b , c ; // Declares three ints, a, b, and c. int a = 10 , b = 10 ; // Example of initialization byte B = 22 ; // initializes a byte type variable B. doub...