Posts

Showing posts with the label widening casting

Type Casting (Type Conversion) in Java जावा में टाइप कास्टिंग (टाइप कन्वर्शन)

Type casting or Type Conversion refers to the process of converting one data type into another within a specific statement or expression. In Java, there are two main types of type casting: टाइप कास्टिंग या टाइप कन्वर्शन के अंतर्गत किसी विशेष स्टेटमेंट या एक्सप्रेशन में एक डेटा टाइप को दूसरे डेटा टाइप में बदला जाता है। जावा में टाइप कास्टिंग के दो मुख्य प्रकार होते हैं: a) Widening Casting (Implicitly) वाइडनिंग कास्टिंग (स्वचालित रूप से) :- Converting a smaller data type into a larger data type is called widening casting or implicit casting . एक छोटे डेटा टाइप को बड़े डेटा टाइप में परिवर्तित करना वाइडनिंग कास्टिंग या स्वचालित कास्टिंग कहलाता है। Conversion order (रूपांतरण क्रम): byte → short → char → int → long → float → double Example / उदाहरण: int i = 5; double j = i; // Implicit casting - from int to double System.out.println(i); // Output: 5 System.out.println(j); // Output: 5.0 b) Narrowing Casting (Manually) नैरोविंग कास्टिंग (मैन्युअली) :- Converting a l...