software development (55)

Java basics: Dates and Time

Local date Now Let's start with the basics, we just want to represent the date today and print that local date now: public class TimeTest { public static void main(String[] args) { LocalDate now = LocalDate.now(); System.out.println(now); } } output: 2022-08-29 Process finished with exit…

Continue reading...

Java basics: Optionals

What are Optionals? For the the number one use case for them has to do with null values. So whenever we're dealing with objects in Java, we store references to objects in variables. And those variables may or may not actually be pointing back to…

Continue reading...

Java basics: Generics

What are Generics? What if we could write a single sort method that sort the elements in an Integer array, a String array, or an array of any type that supports ordering? Java Generics enable programmers to specify, with a single method declaration, a set…

Continue reading...

Java basics: Exceptions

What are Exceptions? An exception is an event, commonly it is a problem that arises during the execution of a program. When an Exception occurs the normal program is disrupted and the program/Application terminates abnormally, which is not recommended. Unexpected termination of an Application is…

Continue reading...

Capture Groups in Java

Capture Groups Im letzten Post haben wir einen kleinen Einstieg in Regex mit Java gemacht. Nun sehen wir uns an, wie man Regex Pattern in Java mittels Capture Groups anwenden kann: String regex = "(1[-.\\s])?(\\d{3}[-.\\s]?)(\\d{3}[-.\\s]?)\\d{4}"; String phoneNumber = "12.523.231.4234"; Pattern pat = Pattern.compile(regex); Matcher mat =…

Continue reading...