FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
From Java to Kotlin: How Would You Rewrite This Class?
NewsProgramming Languages

From Java to Kotlin: How Would You Rewrite This Class?

via Dev.toFelipe Cezar1mo ago

Let's play a little game. You're a developer who just received a task: "Take this Java class and rewrite it in Kotlin — keeping the exact same behavior." Here's the Java class you've been handed: public class AlunoJava { private String codigo ; private String nome ; private int numero = 0 ; private String texto = "EscolaX" ; public AlunoJava ( String codigo , String nome ) { this . codigo = codigo ; this . nome = nome ; } } Take a moment. How would you write this in Kotlin? 🤔 Understanding What This Class Does Before jumping to Kotlin, let's break down what this Java class actually contains: Two private fields ( codigo and nome ) that are set via the constructor Two private fields with default values ( numero = 0 and texto = "EscolaX" ) A constructor that receives codigo and nome as parameters and assigns them using this Simple enough. Now let's talk about how Kotlin handles each of these. Step 1: The Class Declaration In Java, you write: public class AlunoJava { ... } In Kotlin, class

Continue reading on Dev.to

Opens in a new tab

Read Full Article
18 views

Related Articles

The Best E-Readers (2026): Kobo, Kindle
News

The Best E-Readers (2026): Kobo, Kindle

Wired • 8h ago

News

From Scrolling to Creating The Shift That Changed Me

Medium Programming • 8h ago

Best WiiM Streamers (2026): Simplify Your Sound With WiiM Streaming Gear
News

Best WiiM Streamers (2026): Simplify Your Sound With WiiM Streaming Gear

Wired • 8h ago

Retrospec Judd Rev 2 Electric Folding Bike Review: Affordable, Simple, Easy to Store
News

Retrospec Judd Rev 2 Electric Folding Bike Review: Affordable, Simple, Easy to Store

Wired • 9h ago

These car gadgets are worth every penny
News

These car gadgets are worth every penny

ZDNet • 9h ago

Discover More Articles