Skip to main content

Type Casting In Java

Java Type Casting 

•     Type casting is a way of converting data from one data type to another data type. This process of data conversion is also known as type conversion.

There are two types of Casting in Java

1) Widening Casting 

2) Narrowing Casting 



Widening Casting:  In this type, Java automatically converts one data type to another data type. Widening typecasting is also known as Implicit conversion or Casting down.

Narrowing Casting: In this type, the programmer manually converts one data type to another datatype using Round brackets. Narrowing typecasting is also known as Explicit Conversion or Casting up.

 

Comments

Popular posts from this blog

Data Types In SQL

  Data Types In SQL W hat is Data Type? A data type as the name suggests it is the type or category to which the data belongs to. A data type specifies a particular type of data, such as integer, floating-point, Boolean, etc. In SQL, the data type defines the type of data to be stored in each column of a table. SQL data types can be broadly divided into three categories 1.       Numeric Data Types 2.       String Data Types 3.       Data & Time Data Types Numeric Data Types String Data Types Data&Time DataTypes BIT CHAR(SIZE) DATE TINYINT VARCHAR(SIZE) TIME SMALLINT TEXT(SIZE) DATETIME MEDIUMINT TINYTEXT(SIZE) TIMESTAMP INT MEDIUMTEXT(SIZE) YEAR BIGINT LONGTEXT   ...

Switch Statement In Java

Switch Statement:  The switch statement is just like if-else-if ladder statement. It executes one statement from multiple conditions. It works with a byte, short, int, long, and String. In other words, we can say the Switch case statement is a substitute for a long if statement that compares to several integral values. Syntax of Switch statement in java Enhance Switch or Switch With Arrow: The new syntax uses the -> operator instead of the colon we're used to with switch statements. Also, there's no break keyword. Another addition is the fact that we can now have comma-delimited criteria. Syntax of Enhance Switch in java  

Conditional Statements In Java

  Conditionals Statement   A conditional statement  is a set of rules performed if a certain condition is met. A conditional statement begins with the keyword if followed by parentheses. The result of the evaluation is true or false. ·       ‘ if ‘ statement ·       ‘ if-else ‘ statement ·         Nested ‘ if ‘ statement ·       ‘ if-else - if ‘ statement IF statement: ‘IF’ statement is the most basic and simple statement among all the statements. For example- if a value is less than 0, return “Negative value”. Let’s see an example- IF-ELSE statement: The if-else is statement is an extended version of If. Let’s see an example- Nested IF-ELSE statement : In Java, when there is an if statement inside another if statement then it is known as nested if-else. Let’s see an example- IF-ELSE-IF: ‘ if-else-if ’ statement is used when we need to check mul...