Posts

Showing posts from August, 2020

Comparison Logical and Bitwise Operator ( Java Part - 4 )

J ava Comparison Operators Comparison operators are used to compare two values: Operator Name Example Try it == Equal to x == y Try it » != Not equal x != y Try it » > Greater than x > y Try it » < Less than x < y Try it » >= Greater than or equal to x >= y Try it » <= Less than or equal to x <= y Try it » Java Logical Operators Logical operators are used to determine the logic between variables or values: Operator Name Description Example Try it &&  Logical and Returns true if both statements are true x < 5 &&  x < 10 Try it » ||  Logical or Returns true if one of the statements is true x < 5 || x < 4 Try it » ! Logical not Reverse the result, returns false if the result is true !(x < 5 && x < 10) Try it » Java Bitwise Operators Bitwise operators are used to perform binary logic with the bits of an integer or long integer. Operator Description Example Same as Result Decimal & AND -

Type Casting in Java ( Java Part -3 )

Type Casting in Java  Type casting is the practice of converting a data type from one type to another. In Java there are two type of type conversions. The type casting is fully similar to that of type conversion in C and C++. 1. Widening Casting : - This is used to convert from smaller range data type to larger range datatype. Generally these are done automatically. byte  ->  short  ->  char  ->  int  ->  long  ->  float  ->  double 2 Narrowing Casting :- This is used to convert from larger data type to smaller data type. Generally this type of type conversion is done manually. double  ->  float  ->  long  ->  int  ->  char  ->  short  ->  byte