Prev Next

Java / Java Record Keyword

What is the difference between a class and a record in Java?

Records are immutable data classes that require only the type and name of fields. So ,the main difference between class and record type in Java is that a record has the main purpose of storing data, while a class defines responsibility. Records are immutable, while classes are not.

More Related questions...

Show more question and Answers...


Comments & Discussions