Type Casting in Java Part 8 - JAVA ថ្នាក់ទី១ | JAVA For Beginner

Published on ● Video Link: https://www.youtube.com/watch?v=44CPffHSHCQ



Category:
Tutorial
Duration: 26:20
64 views
4


#រៀនសរសេរកូដជាមួយចិត្រា #javaprogramming #javabasics #codingwithchitra #sololearncoding
JAVA ថ្នាក់ទី១ | JAVA For Beginner
អ្វីទៅជា Type Casting in Java?
Type Casting គឺសំដៅទៅលើការផ្តល់ តម្លៃទៅអោយ primitive data type មួយទៅកាន់ primitive data type ផ្សេងទៀត
នៅក្នុងភាសា Java មាន Type Casting ចំនួន ២ គឺ​:
១) Widening Casting(Automatically)
២) Narrowing Casting(Manually)

Widening Casting
អ្វីទៅជា Widening Casting(Automatically) ?
យើងអាចហៅវាម្យ៉ាងទៀតថា implicit type casting
គឺជាការបំប្លែងទិន្នន័យពីតូចទៅធំ
វាផ្លាស់ប្តូរប្រភេទទិន្នន័យនៃអញ្ញាត នៅកំឡុងពេល Compile Time
ពុំមានការបាត់បង់ទិន្នន័យនោះទេ
លំដាប់នៃប្រភេទទិន្នន័យនៅក្នុងភាសា Java:
byte → short → char → int → long → float → double
ឧទាហរណ៍
int a = 9;
double b = a; //Automatically casting int to double

អ្វីទៅជា Narrowing Casting(Manually) ?
អាចហៅម្យ៉ាងទៀតថា explicit type casting ឫ explicit type conversion
គឺជាការបំប្លែងទិន្នន័យពីធំទៅតូច
អាចមានការបាត់បង់ទិន្នន័យ
ចាំបាច់ត្រូវប្រើសញ្ញារង្វង់ក្រចកដើម្បី casting
លំដាប់នៃប្រភេទទិន្នន័យនៅក្នុងភាសា Java:
double → float → long→ int → short→ byte

ឧទាហរណ៍
double a = 4.4;
int b = (int) a; //manually casting: double to int


លំហាត់: Type Casting

1. Declare a variable double num1 and assign it the value 3.14.
2. Create an int variable roundedNum and assign it the rounded value of num1 using explicit type casting.
3. Print the value of roundedNum to the console.
4. Declare a byte variable byteValue and assign it the value 128.
5. Create a short variable shortValue and assign it the value of byteValue using explicit type casting.
6. Print the value of shortValue to the console.
7. Declare a long variable longValue and assign it the value 9876543210.
8. Create an int variable intValue and assign it the value of longValue using explicit type casting.
9. Print the value of intValue to the console.
10. Declare a float variable floatValue and assign it the value 2.71828.
11. Create a double variable doubleValue and assign it the value of floatValue using explicit type casting.
12. Print the value of doubleValue to the console.

កម្រងវីដេអូមេរៀន JAVA ថ្នាក់ទី១👉 https://youtube.com/playlist?list=PLSJTJj3gU6qhkjSEUmgBKGJnn0ob1NZSu&si=rcvL8CwF_5EGx_2n

កម្រងវីដេអូមេរៀន Python 👉 https://youtube.com/playlist?list=PLSJTJj3gU6qimVFO-iV1pOsxTujdIEAqo&si=EyC1cjq73QNGJYI_


YouTube Channel 👉 https://www.youtube.com/@codingwithchitra
Facebook Page 👉 https://www.facebook.com/khmshared
Telegram Channel 👉 https://t.me/codingwithchitra

0:00 Introduction
3:32 Type Casting in Java
5:47 Widening Casting (Automatically Casting)
7:42 Narrowing Casting (Manually Casting)
10:20 Practise
22:25 Quiz
25:23 Exercise




Other Videos By Coding with Chitra-សរសេរកូដជាមួយចិត្រា


2024-04-23The Unary Operators in Java Part 9.2 - JAVA ថ្នាក់ទី១ | JAVA For Beginner
2024-04-23កំណែលំហាត់ក្នុងមេរៀនទី 7.2 | ប្រភេទ​ទិន្នន័យ​នៅក្នុង​ចាវ៉ា - Data Types in Java Part 7.2.3
2024-04-22Part 7.2.2 កំណែលំហាត់ក្នុងមេរៀន ប្រភេទទិន្នន័យជា លេខគត់ byte, short, int long Part 7.2
2024-04-22Part 7.2.1 កំណែលំហាត់ក្នុងមេរៀន ប្រភេទទិន្នន័យជា លេខគត់ byte, short, int long Part 7.2
2024-04-21កំណែលំហាត់ក្នុងមេរៀនទី 7.1 | ប្រភេទ​ទិន្នន័យ​នៅក្នុង​ចាវ៉ា - Data Types in Java Part 7.1.1
2024-04-18Part 04-Python - Indentation | Coding Python from 0 to Hero
2024-04-13#music #love #travel #cambodia #cambodianewyear #songkran #songkran2024 #songkranfestival #viralvlog
2024-04-11Part 03-Python - Environment Setup | Coding Python from 0 to Hero
2024-04-10The arithmetic & Assignment Operators in Java Part 9.1 - JAVA ថ្នាក់ទី១ | JAVA For Beginner
2024-04-03Part 02-ការណែនាំអំពី ភាសា Python | Introduction to Python | Coding Python from 0 to Hero
2024-04-02Type Casting in Java Part 8 - JAVA ថ្នាក់ទី១ | JAVA For Beginner
2024-04-01Part 01-ការណែនាំអំពី សរសេរកូដ Python ពីចំណុច ០ ទៅជាវិរៈបុរស | Coding Python from 0 to Hero
2024-03-30Coding Python from Zero to Hero with Chitra - coding Song
2024-03-25ដំណើរ​កម្សាន្ត​ទៅ​កាន់​កោះ​រ៉ុង​ #kohrong #relaxing #enjoylife #enjoyment #enjoytime #travelvlog
2024-03-14Tech Talk 001-How to use AI to create images
2024-03-13ប្រភេទទិន្នន័យជាតួអក្សរ char data type នៅក្នុង Primitive Data Types in Java Part 7.5
2024-03-12#javabasics #javaprogramming #codingwithchitra #coding #sololearncoding #codinglife #javatutorial
2024-03-12#javabasics #javaprogramming #codingwithchitra #codinglife #javatutorial #java #javaforbeginner
2024-03-11កំណែលំហាត់ 6.5.1 -​ Managing Students ក្នុងមេរៀន ប្រភេទអញ្ញាតជា Static/Class Variables
2024-03-09ប្រភេទទិន្នន័យជា boolean data type នៅក្នុង Primitive Data Types in Java Part 7.4
2024-03-08#youtube #shorts #javabasics #javaprogramming #codingwithchitra #coding #javatutorial #codinglife



Tags:
java
javaforbeginner
coding with chitra
សរសេរកូដជាមួយចិត្រា
java for beginners
java tutorial for beginners
java programming for beginners
beginners
java training
java course
java programming
java 8 course
java tutorial
java 8 tutorial
java 8
java 8 tutorial with examples
java 12
java programming tutorial
learn to code
learn java
tutorial
programming
រៀនសរសេរកូដ
រៀនចាវ៉ា
core java
core java programming
codecademy
codekhmer
codecademy java
sololearn coding