mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 07:33:57 +00:00
Minor edits
This commit is contained in:
parent
229dcd2b06
commit
ac96ae7d96
@ -224,12 +224,11 @@ public class LearnJava {
|
||||
// Strings
|
||||
String fooString = "My String Is Here!";
|
||||
|
||||
// Java 14 onwards - Text Blocks
|
||||
// Text blocks
|
||||
vat textBlock = """
|
||||
This is a <Text Block> in Java
|
||||
""";
|
||||
|
||||
|
||||
// \n is an escaped character that starts a new line
|
||||
String barString = "Printing on a new line?\nNo Problem!";
|
||||
// \t is an escaped character that adds a tab character
|
||||
@ -870,8 +869,8 @@ public abstract class Mammal()
|
||||
}
|
||||
}
|
||||
|
||||
//Java Records (introduced in Java 14, finalized in Java 16) are a concise way to define immutable data carrier classes,
|
||||
//automatically generating boilerplate code like constructors, equals(), hashCode(), and toString().
|
||||
// Java Records are a concise way to define immutable data carrier classes, automatically
|
||||
// generating boilerplate code like constructors, equals(), hashCode()and toString().
|
||||
// This automatically creates an immutable class Person with fields name and age.
|
||||
public record Person(String name, int age) {}
|
||||
Person p = new Person("Alice", 30);
|
||||
|
Loading…
Reference in New Issue
Block a user