Hello Everyone👋👋 Explain different data types in Java There are 2 types of data types in Java as mentioned below: 1. Primitive Data Type: Primitive data are single values with no special capabilities. There are 8 primitive data types: boolean: stores value true or false byte: stores an 8-bit signed two's complement integer char: stores a single 16-bit Unicode character short: stores a 16-bit signed two’s complement integer int: stores a 32-bit signed two’s complement integer long: stores a 64-bit two’s complement integer float: stores a single-precision 32-bit IEEE 754 floating-point double: stores a double-precision 64-bit IEEE 754 floating-point 2. Non-Primitive Data Type: Reference Data types will contain a memory address of the variable's values because it is not able to directly store the values in the memory. Types of Non-Primitive are mentioned below: Strings Array Class Object Interface #Java #backend #frontend #inheritance #FullStack #interface #software #AI #developer #code #super #programming #aws #class #object #Angular #React #Javascript #lambda #API #volatile #transient #constructor #Stream #SpringBoot #Hibernate #JDBC #GenAI #interview
Java Data Types: Primitive and Non-Primitive Explained
More Relevant Posts
-
🚀 Day 17 | Java Backend Development – 100 Days Challenge 📚 Topics Covered Today: Types of SQL Statements: DDL, DML, DCL, TCL CREATE TABLE with Constraints Primary Key Foreign Key ALTER TABLE – ADD, MODIFY, DROP columns DML Operations: INSERT, UPDATE, DELETE JOINS explained: INNER, LEFT, RIGHT, FULL Aggregations, GROUP BY & HAVING with Joins Today was all about relational data modeling and complex data querying — core skills for any backend developer. Understanding joins and constraints is key to writing efficient and accurate database queries. Backend isn’t complete without strong SQL fundamentals 💪 On to Day 18 🚀 #SQL #Databases #BackendDevelopment #SpringBoot #Java #100DaysOfCode #Day17 #LearningInPublic #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 How Java HashMaps Actually Work (Under the Hood) Ever wondered how a HashMap manages to find your data almost instantly, even with millions of records? It’s not magic—it’s just clever engineering. 🧠 Think of a HashMap like a giant post office with 16 initial "mailboxes" (Buckets). Here is the 5-step journey of your data: 1️⃣ The Hashing Secret When you give the map a Key, Java doesn't just store it. It calls the .hashCode() method. This turns your key into a unique integer. This number is the "DNA" of your key. 2️⃣ Finding the Right "Bucket" Java takes that Hash Code and performs a bit of math to fit it into the current array size. Formula: index = hashCode & (n - 1) This tells the Map exactly which "mailbox" (index) the data belongs in. 3️⃣ Dealing with "Traffic Jams" (Collisions) What if two different keys end up with the same index? This is a Collision. In Java, the bucket doesn't just overwrite the data. It starts a Linked List at that index, stacking the entries one after another. 4️⃣ The "Power Up" (Treeification) If a single bucket gets too crowded (more than 8 items), Java 8+ performs a "Power Up." It converts that slow Linked List into a Red-Black Tree. This ensures that even in the worst-case scenario, searching stays lightning-fast. 5️⃣ The Expansion (Resizing)A HashMap doesn't like being cramped. Once it is 75% full (the Load Factor), it doubles its size. It then "re-hashes" everything to distribute the data into the new, larger space to keep performance at O(1). 💡 The Golden Rule: If you use custom objects as Keys, always override hashCode() and equals(). If you don't, your HashMap will lose its "memory" and you'll end up with duplicate entries or null results! #Java #Programming #SoftwareEngineering #DataStructures #BackendDevelopment
To view or add a comment, sign in
-
-
🚀 Core Java – Day 6 📌 Topic: Data Types (Primitive Data Types) Today, I learned about Data Types in Core Java. 👉 Meaning: Data types help convert real-world data into binary format (0s and 1s) so that a computer can store and understand it. 💡 Real-world data cannot be stored directly because it is not in binary form, and computers understand only binary values. 🗂️ Real-world data can be categorized into 7 types: 1️⃣ Integer data 2️⃣ Real number data 3️⃣ Character data 4️⃣ Yes/No data 5️⃣ Audio 6️⃣ Video 7️⃣ Still pictures (Images) 📌 Java Data Types are categorized into two types: 1️⃣ Primitive Data Types 2️⃣ Non-Primitive Data Types 🔹 Primitive Data Types a) Integer Type Data Stores whole numbers (positive, negative, and zero) without decimals 📌 Example: Age of a person byte → 1 byte (8 bits), range: -128 to 127 short → 2 bytes (16 bits), range: -32,768 to 32,767 int → 4 bytes (32 bits), range: -2,147,483,648 to 2,147,483,647 long → 8 bytes (64 bits), range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 📝 Note: Use L suffix for long values. b) Real Number Type Data Stores numbers with decimal values float → 4 bytes (example: 13.4f) double → 8 bytes (example: 9.34324) c) Character Type Data Stores a single character such as letters, digits, or symbols char → 2 bytes d) Boolean Type Data Stores true/false or yes/no values boolean → Size depends on JVM Commonly used in conditions and logical operations ✨ Understanding data types is essential for building a strong Java foundation. #CoreJava #Day6 #JavaBasics #LearningJourney #Programming
To view or add a comment, sign in
-
-
🚀 The char Data Type (Java) The `char` data type represents a single 16-bit Unicode character. It is used to store characters such as letters, digits, and symbols. Character literals are enclosed in single quotes (e.g., `'A'`, `'5'`, `'$'`). The `char` type can also represent Unicode escape sequences for special characters. Understanding `char` is fundamental for working with text and strings in Java. #Java #JavaDev #OOP #Backend #professional #career #development
To view or add a comment, sign in
-
-
Looking to simplify your Data Access Object (DAO) in Java? Check out this brilliant piece by Tim Kelly on Foojay. He clearly guides you through abstracting data access using the DAO pattern, which promotes low coupling and high cohesion. By following the DAO pattern, you can liberate your business logic from data access specifics. Full article here: https://lnkd.in/e6A-7sRs #Java #DAO #DesignPatterns #Foojay
To view or add a comment, sign in
-
When we store data in a program, one question naturally comes up: ❓𝐖𝐡𝐚𝐭 𝐤𝐢𝐧𝐝 𝐨𝐟 𝐝𝐚𝐭𝐚 𝐢𝐬 𝐭𝐡𝐢𝐬? In real life, we already treat information differently. • A name is treated as text. • An age is treated as a number. Programming works the same way — Java just needs this difference to be stated clearly. That’s where data types come in. 🛠️𝐃𝐚𝐭𝐚 𝐓𝐲𝐩𝐞𝐬 Data types tell Java what kind of data a variable can store. Java classifies data types into two main categories: 🔹 Primitive Data Types (8 types) Primitive data types are predefined (built-in) in Java, which means Java already knows how to store and handle them. They include: byte, short, int, long, float, double, char, boolean Each primitive type has a fixed size and specific behavior, which helps Java manage memory efficiently. 🔹 Non-Primitive Data Types Non-primitive data types are user-defined or reference types. They are created using primitive data types and are used to store more complex data. Examples include: • String • arrays • classes • objects In simple terms: 🧩 Primitive data types are predefined and store actual values. 🏷️ Non-primitive data types are user-defined and store references to data. By defining a data type, Java knows: 🧠 how much memory to allocate ⚙️ what operations are allowed 🔄 how the value should behave during execution This prevents confusion and unexpected errors while the program runs. That’s why data types matter: they remove ambiguity and keep programs predictable and reliable. 🧩 Variables hold information. 🏷️ Data types tell Java how to handle it. 🤔 𝑰𝒇 𝒗𝒂𝒓𝒊𝒂𝒃𝒍𝒆𝒔 𝒂𝒏𝒅 𝒅𝒂𝒕𝒂 𝒕𝒚𝒑𝒆𝒔 𝒅𝒆𝒇𝒊𝒏𝒆 𝒘𝒉𝒂𝒕 𝒅𝒂𝒕𝒂 𝒂 𝒑𝒓𝒐𝒈𝒓𝒂𝒎 𝒘𝒐𝒓𝒌𝒔 𝒘𝒊𝒕𝒉, 𝒉𝒐𝒘 𝒅𝒐𝒆𝒔 𝒂 𝑱𝒂𝒗𝒂 𝒑𝒓𝒐𝒈𝒓𝒂𝒎 𝒈𝒆𝒕 𝒕𝒉𝒂𝒕 𝒅𝒂𝒕𝒂 𝒇𝒓𝒐𝒎 𝒕𝒉𝒆 𝒖𝒔𝒆𝒓? 💬 If you know the answer, feel free to share your thoughts in the comments. Here’s a small Java program demonstrating different data types in action... #Java #CoreJava #JavaBasics #LearningJourney #Programming #BuildInPublic
To view or add a comment, sign in
-
-
// The Rule of Thumb Simple queries -> Java. Heavy lifting -> DB. Here is why... I’ve been seeing too many projects lately where business logic is buried deep inside Stored Procedures. It makes debugging a nightmare and ties you strictly to one database. We need to move that logic back to the Application Layer. My rule of thumb for where the code should live: 1) Simple/Medium queries: Keep it in Java (JPA or native SQL). 2) Complex joins: Use Native SQL in the repository, but keep the logic business-driven. 3) Heavy data lifting: Stored Procedures. But strictly as a last resort for performance. With modern Java features like Records and Lambdas, there’s really no excuse to hide logic in the DB anymore. It’s about readability and decoupling, not just "getting it to work." Happy Coding ✌ #SystemArchitecture #Java #BackendEngineering #ScalableSystems #TechLeadership #Database #EngineeringBestPractices
To view or add a comment, sign in
-
At Coroot, we collect anonymous usage stats. It’s super useful: we see what features people use most and we can catch performance issues before anyone reports them. The moment you accept input from the outside world, you also get a steady stream of SQL and code injection attempts. We expected that from day one, and the system is built to handle it safely. What’s funny is how diverse the payloads are. In one sample we saw: - SQL injection probes for MySQL, Postgres, SQL Server, SQLite, and even Oracle - Java template and expression attacks (Freemarker, Velocity, OGNL/Struts-style) - Deserialization / unsafe parsing attempts for Java, Python, and Ruby - Lots of ping, nslookup, and curl calls to random domains to check “did it run?” Still, it’s kind of fun to see what shows up in the data. Data always tells a story🙂
To view or add a comment, sign in
-
When I first learned Tree data structures in Java, I felt lost. Arrays were easy. Lists were predictable. Everything was linear. Then Trees showed up. 1 / \ 2 3 / \ / \ 4 5 6 7 I just don't know how to read this. If you’ve ever felt the same confusion, I wrote a detailed breakdown, starting from counting nodes, understanding levels, all the way to inOrder traversal. 👉 Read the full explanation on my website here: https://lnkd.in/g6kJjRTC #Java #DataStructures #BinaryTree #SoftwareEngineering #BackendDevelopment
To view or add a comment, sign in
-
-
JSON Has a Cost JSON seems to be everywhere these days. Many application developers like it across all sorts of languages, C#, JAVA, Python, and more. They use it for transferring information between systems, and are comfortable serializing hierarchical object data into JSON from text and de-serializing it back into its various elements. For those of us working in relational databases, JSON seems like a blob of information that isn't easily queried, indexed, or stored....
To view or add a comment, sign in
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development