<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/what-is-flattenning---cracking-the-java-coding-interview-javalanguage-javacoding-javatips-1zny9uvhd" -->

---
title: What is flattenning? - Cracking the Java Coding...
description: Flattening refers to storing an object's content directly as a value rather than as a reference, avoiding the CPU cache misses and memory overhead of wrapper...
canonical: https://daily.dev/posts/what-is-flattenning---cracking-the-java-coding-interview-javalanguage-javacoding-javatips-1zny9uvhd
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: What is flattenning? - Cracking the Java Coding Interview #javalanguage #javacoding #javatips | daily.dev
og:description: Flattening refers to storing an object's content directly as a value rather than as a reference, avoiding the CPU cache misses and memory overhead of wrapper...
og:url: https://daily.dev/posts/what-is-flattenning---cracking-the-java-coding-interview-javalanguage-javacoding-javatips-1zny9uvhd
og:image: https://api.daily.dev/og/posts/1zNY9uvHD.png
og:image:alt: What is flattenning? - Cracking the Java Coding Interview #javalanguage #javacoding #javatips
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# What is flattenning? - Cracking the Java Coding Interview #javalanguage #javacoding #javatips

**[Java \(Official Oracle\)](https://daily.dev/sources/java-oracle)** · 1 min read · 0 upvotes · 0 comments

## Summary

Flattening refers to storing an object's content directly as a value rather than as a reference, avoiding the CPU cache misses and memory overhead of wrapper objects like Integer. A single int needs only 32 bits, but wrapping it in an Integer object with a reference, header, and alignment padding can balloon that to around 128 bits. Project Valhalla introduces value objects designed to carry values that can be flattened this way, though the constraints around flattening are complex.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=_DF3qwP3vcU>

## Questions this post answers

### What does flattening mean in the context of Java and Project Valhalla?

Flattening means storing an object's content directly as a value instead of storing a reference to a separately allocated object. For example, a wrapped Integer normally requires a reference plus an object header and alignment padding, potentially using around 128 bits, versus just 32 bits for a raw int. Project Valhalla introduces value objects specifically designed to be flattened this way, reducing memory use and avoiding reference-following cache misses.

_Developers tracking JVM performance changes follow project valhalla and value object progress on daily.dev._

### Why is wrapping a primitive int in an Integer object inefficient in Java?

Wrapping an int in an Integer object is inefficient both in CPU and memory terms. CPU-wise, reading the value requires following a reference, which can cause a cache miss and hurt performance. Memory-wise, a raw int only needs 32 bits, but an Integer object adds a reference, an object header, and alignment padding, potentially consuming around 128 bits total.

_Java developers optimizing memory-heavy collections can dig deeper into object overhead topics on daily.dev._

## Similar posts on daily.dev

- [Optimizing Java Class Metadata in Project Valhalla – Inside.java](https://daily.dev/posts/optimizing-java-class-metadata-in-project-valhalla-inside-java-tsiljbslw) · Inside Java · 6 upvotes · 0 comments
- [Java’s biggest language change in a decade is finally landing. It took 197,000 lines of code.](https://daily.dev/posts/java-s-biggest-language-change-in-a-decade-is-finally-landing-it-took-197-000-lines-of-code--8eeespmnb) · The Next Web · 39 upvotes · 1 comments
- [Value Classes Still Need Compiler Sympathy](https://daily.dev/posts/value-classes-still-need-compiler-sympathy-6gmnyemca) · Inside Java · 0 upvotes · 0 comments

---

Tags: [#java](https://daily.dev/tags/java)

[View this post on daily.dev](https://daily.dev/posts/what-is-flattenning---cracking-the-java-coding-interview-javalanguage-javacoding-javatips-1zny9uvhd)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"What is flattenning? - Cracking the Java Coding Interview #javalanguage #javacoding #javatips","url":"https://daily.dev/posts/what-is-flattenning---cracking-the-java-coding-interview-javalanguage-javacoding-javatips-1zny9uvhd","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/what-is-flattenning---cracking-the-java-coding-interview-javalanguage-javacoding-javatips-1zny9uvhd"},"datePublished":"2026-09-23T10:24:44.126Z","dateModified":"2026-09-23T10:25:01.203Z","description":"Flattening refers to storing an object's content directly as a value rather than as a reference, avoiding the CPU cache misses and memory overhead of wrapper...","image":"https://i.ytimg.com/vi/_DF3qwP3vcU/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/_DF3qwP3vcU/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Java (Official Oracle)","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Java (Official Oracle)","logo":"https://media.daily.dev/image/upload/s--SM9hIYUY--/f_auto,q_auto/v1773648791/logos/java-oracle?_a=BAMAMiiu0","url":"https://daily.dev/sources/java-oracle"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/what-is-flattenning---cracking-the-java-coding-interview-javalanguage-javacoding-javatips-1zny9uvhd","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"java","timeRequired":"PT1M","video":{"@type":"VideoObject","name":"What is flattenning? - Cracking the Java Coding Interview #javalanguage #javacoding #javatips","description":"Flattening refers to storing an object's content directly as a value rather than as a reference, avoiding the CPU cache misses and memory overhead of wrapper...","thumbnailUrl":"https://i.ytimg.com/vi/_DF3qwP3vcU/sddefault.jpg","uploadDate":"2026-09-23T10:24:44.126Z","duration":"PT1M","url":"https://api.daily.dev/r/1zNY9uvHD","embedUrl":"https://www.youtube.com/embed/_DF3qwP3vcU"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Java (Official Oracle)","item":"https://daily.dev/sources/java-oracle"},{"@type":"ListItem","position":3,"name":"What is flattenning? - Cracking the Java Coding Interview #javalanguage #javacoding #javatips"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/what-is-flattenning---cracking-the-java-coding-interview-javalanguage-javacoding-javatips-1zny9uvhd#faq","mainEntity":[{"@type":"Question","name":"What does flattening mean in the context of Java and Project Valhalla?","acceptedAnswer":{"@type":"Answer","text":"Flattening means storing an object's content directly as a value instead of storing a reference to a separately allocated object. For example, a wrapped Integer normally requires a reference plus an object header and alignment padding, potentially using around 128 bits, versus just 32 bits for a raw int. Project Valhalla introduces value objects specifically designed to be flattened this way, reducing memory use and avoiding reference-following cache misses. Developers tracking JVM performance changes follow project valhalla and value object progress on daily.dev."}},{"@type":"Question","name":"Why is wrapping a primitive int in an Integer object inefficient in Java?","acceptedAnswer":{"@type":"Answer","text":"Wrapping an int in an Integer object is inefficient both in CPU and memory terms. CPU-wise, reading the value requires following a reference, which can cause a cache miss and hurt performance. Memory-wise, a raw int only needs 32 bits, but an Integer object adds a reference, an object header, and alignment padding, potentially consuming around 128 bits total. Java developers optimizing memory-heavy collections can dig deeper into object overhead topics on daily.dev."}}]}
```

