Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
💻

The Bored Dev theboreddev

💭
💻
View GitHub Profile
View MultiLineStringExample.java
final String multiLineText = """
{"widget": {
"debug": "on",
"window": {
"title": "Sample Konfabulator Widget",
"name": "main_window",
"width": 500,
"height": 500
},
"image": {\s
View MultiLineStringExample.java
final String text = "{\"widget\": {\n" +
" \"debug\": \"on\",\n" +
" \"window\": {\n" +
" \"title\": \"Sample Konfabulator Widget\",\n" +
" \"name\": \"main_window\",\n" +
" \"width\": 500,\n" +
" \"height\": 500\n" +
" },\n" +
" \"image\": { \n" +
" \"src\": \"Images/Sun.png\",\n" +
View NewDayOfTheWeekExample.java
final DayOfTheWeek dayOfTheWeek = DayOfTheWeek.THURSDAY;
int position = switch (dayOfTheWeek) {
case MONDAY -> 1;
case TUESDAY -> 2;
case WEDNESDAY -> 3;
case THURSDAY -> 4;
case FRIDAY -> 5;
case SATURDAY -> 6;
case SUNDAY -> 7;
View DayOfTheWeekExample.java
final DayOfTheWeek dayOfTheWeek = DayOfTheWeek.THURSDAY;
int position = 0;
switch (dayOfTheWeek) {
case MONDAY:
position = 1;
break;
case TUESDAY:
position = 2;
@theboreddev
theboreddev / DayOfTheWeek.java
Created Jul 24, 2020
day_of_week day_of_week
View DayOfTheWeek.java
public enum DayOfTheWeek {
MONDAY,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY,
SUNDAY
}
View AgeRange.java
public enum AgeRange {
UNDER_TWENTY,
UNDER_THIRTY,
UNDER_FORTY,
UNDER_FIFTY,
FIFTY_OR_MORE
}
View AddressRecord.java
public record AddressRecord(String firstLine, String secondLine, String postCode) {
}
View EmployeeRecord.java
public record EmployeeRecord(String firstName, String surname, int age, AddressRecord address, double salary) {
}
View Address.java
import java.util.Objects;
public class Address {
private final String firstLine;
private final String secondLine;
private final String postCode;
public Address(String firstLine, String secondLine, String postCode) {
this.firstLine = firstLine;
this.secondLine = secondLine;
@theboreddev
theboreddev / Employee.java
Created Jul 24, 2020
employee_before_java_14
View Employee.java
package com.theboreddev.java14;
import java.util.Objects;
public class Employee {
private final String firstName;
private final String surname;
private final int age;
private final Address address;
private final double salary;