- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Variable Narrowing Example
Narrowing refers to passing a higher size data type like int to a lower size data type like short. It may lead to data loss. Casting is required for narrowing conversion. Following program output will be 44.
public class MyFirstJavaProgram { public static void main(String []args) { int a = 300; byte b = (byte)a; // narrowing System.out.println(b); } }
Advertisements