RUVIDEO
Поделитесь видео 🙏

# 26 OOPS | Type Conversion | Type Promotion & Operator In Java Tutorial | Java Basic

For Online Live Training Contact me directly on - 9310683500 (Available on What's App Also)

Type conversion in java
It is the process of converting one type of data in another type.
 Primitive to Primitive.
 Primitive to Object.
 Object to Primitive.
There are two types of Type Conversion: -
1. Type Promotion (Implicit).
2. Type Casting (Explicit).
Type Promotion (Implicit): -
 It is the process of converting one type of data into another type implicitly by java itself.
 If we have data and data does found its exact match so it is implicitly promoted to its higher data type


#Example
 public class Test
 {
 void show(byte b)
 {
 System.out.println("Byte="+b);
 }
 void show(short b)
 {
 System.out.println("short="+b);
 }
 void show(int b)
 {
 System.out.println("int="+b);
 }
 void show(long b)
 {
 System.out.println("long="+b);
 }
 void show(float b)
 {
 System.out.println("float="+b);
 }
 void show(double b)
 {
 System.out.println("double="+b);
 }
 public static void main(String [] args)
 {
 Test t=new Test();
 //t.show(23l);
 //t.show(23);
 t.show(23.67f);
 }
 }

Type Casting (Explicit): -
It is the process of converting one type of data into another type explicitly by java programmer.
#Syntax: -
dataType variableName = (dataType) variableToConvert;
//Java program to illustrate explicit type conversion
class Test
{
public static void main(String[] args)
{
double d = 100.04;
byte b=20;
int c=b;// type promotion

//explicit type casting
long l = (long)d;

//explicit type casting
int i = (int)l;
System.out.println("Double value "+d);

//fractional part will lost
System.out.println("Long value "+l);

//fractional part will lost
System.out.println("Int value "+i);
}
}
Note: - In java, compiler perform operation only on two type of data either int or double.
Note: - Whenever we perform any arithmetic operation then calculation is done on the basis of below formula:
Max (type of first operand, type of second operand, type of third operand…)
Note: - if data type are equals result will be in the same data type.
public class Test
{

public static void main(String[] args)
{

int male=5;
int female=2;

float ratio=(float)male/female;
System.out.println(ratio);

}

}
Output :- 2.5


Stay tuned with me for more upcoming Videos,
don't forget to subscribe my YouTube Channel and share your valuable comments in Comment section down below, i'll be happy t o help you all, your Surya ☺

Storage option url-
https://www.youtube.com/watch?v=KgCfx...

Connect on Socials:-

Facebook:- https://www.facebook.com/AndroJavaTec...
Twitter:- https://twitter.com/AndroJavaTech4U
Google Plus:- https://plus.google.com/u/0/+AndroJav...
LinkedIn:- https://www.linkedin.com/in/androjava...

#TypeCasting #Operators #TypeCasting

java Basic Java Tutorial for beginners
Basic Java Programming for beginners

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «# 26 OOPS | Type Conversion | Type Promotion & Operator In Java Tutorial | Java Basic», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.