Static Import This concept is introduces in 1.5, According to static import, improves readability of the code. But According to world wide experts, static import reduces readability and increases the confusion of the code. Hence if there is no specific requirement, it is not recommended to use static import. When we are using static import, […]
Month: December 2018
Evaluation Order of Java Operand Before applying any operator, all the Operands should be evaluated from left to right.
Precedence Of Java Operators Uniary Operators :- [ 1st level [ ], x++, x– ], [ 2nd level ++x, –x, ~, ! ], [ 3rd level new, <type> ]. Arithmetic Operators:- *, /, %, +, – . Shift Operators:- >>, >>>, << . Comparison Operators:- <, <=, >, >=, instance of, == . Bitwise Operators:- […]
New Operator New operator can be used for the creation of Object. Note:- There is no delete operator in java, Destruction of useless Objects will take care by Garbage Collector.
The only ternary operator available in java is conditional operator. int a = ( 10<20 ) ? 30 : 40 ; System.out.println( a) ; // 30 Nesting of conditional operator is also allowed in java. int x = ( 100>200 ) ? 10 : ( (1000>3000) ? 20 : 30 ) ; System.out.println( x) ; […]
Assignments The following is the list of all possible compound assignment operator. + = & = % = – = | = >>> = * = ^ = << = / = >> = In the case of compound assignment operator, the required type casting is performed automatically by the compiler. byte b = 20 […]
Instance Of Operator Syntax:- t instanceof x t ==> Object / Obj reference. x ==> class name / interface Ex:- Thread t = new Thread ( ) ; System.out.println ( t instanceof Thread ) ; // true System.out.println ( t instanceof Object ) ; // true System.out.println ( t instanceof Runnable ) ; // […]
Type Cast Operator There are two types of primitive type castings a possible. implicit type casting explicit type casting Implicit Type Casting Compiler is responsible for this type casting. performed automatically where ever we are assigning smaller value to the bigger data type It is also known as Widening or up casting There is no […]
Short Circuit Operators ( &&, || ) These operators are exactly same as normal operator |, ‘&’ except the following difference. General Operators ( &, | ) Short Circuit Operator ( &&, || ) Both arguments should be evaluated always. Second argument evaluation is optional. Relatively performance is low. Performance is high. Applicable for both […]
Bitwise Operators & –> If both operands are true, then the result will be true. Ι –> If at least one arg is true, then the result is true. ∧ ( XOR ) –> If both args are different the result is true. s.o.p ( true & false ) ; // false s.o.p ( true […]