<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-write-bad-java-code-by-pratik-patel-l2s9uemak" -->

---
title: How to Write Bad Java Code, by Pratik Patel | daily.dev
description: A lightning talk covering common Java performance pitfalls, many of which can be introduced by AI code assistants. Topics include: string concatenation vs...
canonical: https://daily.dev/posts/how-to-write-bad-java-code-by-pratik-patel-l2s9uemak
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Write Bad Java Code, by Pratik Patel | daily.dev
og:description: A lightning talk covering common Java performance pitfalls, many of which can be introduced by AI code assistants. Topics include: string concatenation vs...
og:url: https://daily.dev/posts/how-to-write-bad-java-code-by-pratik-patel-l2s9uemak
og:image: https://api.daily.dev/og/posts/l2s9UeMak.png
og:image:alt: How to Write Bad Java Code, by Pratik Patel
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.

# How to Write Bad Java Code, by Pratik Patel

**[Jfokus](https://daily.dev/sources/jfokus)** · 15 min read · 0 upvotes · 0 comments

## Summary

A lightning talk covering common Java performance pitfalls, many of which can be introduced by AI code assistants. Topics include: string concatenation vs StringBuilder (O(n²) vs efficient), avoiding the 'pyramid of doom' with Optional for null checks, boxing/unboxing overhead in loops, compiling regex patterns only once outside loops, minimizing method calls in hot paths, and avoiding unnecessary synchronization. The JIT compiler handles some of these automatically (method inlining, loop invariant hoisting), but others like string concatenation and regex compilation require manual fixes.

## Full article

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

## Similar posts on daily.dev

- [Java Is Fast. Your Code Might Not Be.](https://daily.dev/posts/java-is-fast-your-code-might-not-be--melyfth7m) · Hacker News · 0 upvotes · 0 comments
- [The Art of Performance Tuning: Why Saving 30% in the Cloud Means Nothing if Your Code Wastes 1000× More](https://daily.dev/posts/the-art-of-performance-tuning-why-saving-30-in-the-cloud-means-nothing-if-your-code-wastes-1000-m-litd1xrxr) · Foojay.io · 1 upvotes · 0 comments

---

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

[View this post on daily.dev](https://daily.dev/posts/how-to-write-bad-java-code-by-pratik-patel-l2s9uemak)

```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":"How to Write Bad Java Code, by Pratik Patel","url":"https://daily.dev/posts/how-to-write-bad-java-code-by-pratik-patel-l2s9uemak","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-write-bad-java-code-by-pratik-patel-l2s9uemak"},"datePublished":"2026-03-16T08:14:09.888Z","dateModified":"2026-03-16T08:21:50.210Z","description":"A lightning talk covering common Java performance pitfalls, many of which can be introduced by AI code assistants. Topics include: string concatenation vs...","image":"https://i.ytimg.com/vi/aIq5Mq3JyNI/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/aIq5Mq3JyNI/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Jfokus","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":"Jfokus","logo":"https://media.daily.dev/image/upload/s--vBtpiVto--/f_auto,q_auto/v1773648822/logos/jfokus?_a=BAMAMiiu0","url":"https://daily.dev/sources/jfokus"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-write-bad-java-code-by-pratik-patel-l2s9uemak","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"performance,java,jvm","timeRequired":"PT15M","video":{"@type":"VideoObject","name":"How to Write Bad Java Code, by Pratik Patel","description":"A lightning talk covering common Java performance pitfalls, many of which can be introduced by AI code assistants. Topics include: string concatenation vs...","thumbnailUrl":"https://i.ytimg.com/vi/aIq5Mq3JyNI/sddefault.jpg","uploadDate":"2026-03-16T08:14:09.888Z","duration":"PT15M","url":"https://api.daily.dev/r/l2s9UeMak","embedUrl":"https://www.youtube.com/embed/aIq5Mq3JyNI"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Jfokus","item":"https://daily.dev/sources/jfokus"},{"@type":"ListItem","position":3,"name":"How to Write Bad Java Code, by Pratik Patel"}]}
```

