Deepak Kale’s Post

💻 Exploring Java Data Types & Literals While revisiting Java fundamentals, I explored how literals work with different data types. Literals are fixed values assigned directly in code, and Java provides some interesting ways to use them. 📌 Here are some useful things I learned: 🔹 Binary Literal (Base 2) We can write numbers in binary using 0b Example: int num = 0b101; // Output: 5 🔹 Hexadecimal Literal (Base 16) We can use 0x to represent hexadecimal values Example: int num2 = 0x7E; // Output: 126 🔹 Using Underscore for Readability Underscores can be used to make large numbers more readable Example: int num3 = 10_00_000; // Output: 1000000 🔹 Scientific Notation (e-notation) Used to represent large values in floating-point numbers Example: double numd = 12e10; 🔹 Character Increment Trick Characters in Java are internally stored as numbers (ASCII/Unicode), so we can increment them: Example: char c = 'a'; c++; // Output: 'b' 📌 In simple terms: These features make Java code more readable and also reveal how data is handled internally. Continuing to strengthen my Java fundamentals step by step 🚀 #Java #Programming #LearningJourney #JavaBasics #BackendDevelopment

  • text

To view or add a comment, sign in

Explore content categories