Types
Boolean
A Boolean is a datatype in programming. This datatype only has 2 modes, it’s either true
or false
. you can translate it to something being on
or off
. You can also see it as a 1
and a 0
. Most programming languages see a 1
as the value true
and 0
as the value false
when put inside an if statement.
String
A string is a datatype. A string is a piece of text. or in some languages you’d say: a string is an array of chars. In programming you would assign variable to be the type of string, and then you can put any piece of text in there, any character combination. It is a thing in every programming language, as far as I know.
Record
The Java record
datatype is like a class, but it automatically handles a few functions like equals()
, hashCode()
, and toString()
. With a regular class, you would have to write or generate these methods manually. Records are inherently immutable. Once an instance is created, its state cannot be changed. This helps prevent many common bugs associated with mutable state. Records are specifically designed for classes whose primary purpose is to carry data
OOP
class
interface
Modifiers
Final
In Java there is a final
modifier, and what it does is it assures that the variable is unchangable. Once you set the value, it’ll be set for life basically. This value can be assigned via the constructor or at a declaration. If you set an object as a final
the properties and fields of this object can still change.
Readonly
In [[C-Sharp|C#]] there is a readonly
modifier. It does the same thing as the Final modifier in Java.
Const
The const
modifier feels the same as the readonly, but there are quite a few differences. In [[C-Sharp|C#]] the const
is declared at the compile time, meaning that it can not be complex things like Objects. And in C# a const
must also be static
.