Java — Final VS Immutability | Code Factory

  • If you don’t want to perform reassignment for the variable then it is a final.
  • If you don’t want to perform any changes in the object then it is a immutable.
final StringBuffer sb = new StringBuffer("Code");
sb.append("Factory");
System.out.println(sb); // CodeFactory
sb = new StringBuffer("Hello"); // CE : cannot assign a value to final variable sb
  1. final variable
  2. final object X
  3. Immutable variable X
  4. Immutable object

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Data Spectrum — language evolution

Creating an Alibaba Cloud Container Service Application with Docker Swarm

Setting up the performance monitoring for your first EC2 deployment (Linux).

What happens when you run the ls -l command

All you need to know about the oracle IAM Upgrade!

Bluehost Vs Weebly

I Used Flutter To Build My Dream App

Submitting data to Google Sheets through a form embedded in WordPress

Google spreadsheet’s screenshot covered with SheetDB form and logos of SheetDB & WordPress

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Code Factory

Code Factory

More from Medium

Authorization vs Authentication

Setting Up Local AEM WKND Dispatcher with Docker | AEM 6.5.x. | AEMCaaS | Fiddler | Windows

start breaking it before a prod release

Breaking it

RateLimiter’s Throttling Mechanism