Search results for: Java

String validation plays a crucial role in Java programming as it helps ensure the correctness and reliability of data processing. Strings are fundamental data types used to store text-based information, such as user inputs, file contents, or database values. However, these strings can often be empty, null, or contain only whitespace characters, which can lead…

Read More Check if a String is Null, Empty or Blank in Java

{ “firstName” : “John”, “lastName”: “Doe”, “gender”: “Male”, “state”: “Texas” } public class Person { private String firstName; private String lastName; private String state; // constructors, getters and setters } public class Person { private String firstName; private String lastName; private String gender; <<<< private String state; } import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @JsonIgnoreProperties(ignoreUnknown = true) public class…

Read More Unrecognized field not marked as ignorable – Java Jackson

synchronized void method() {} public class SynchronizedInstanceMethodExample implements Runnable { public static void main(String[] args) { SynchronizedInstanceMethodExample runnable = new SynchronizedInstanceMethodExample(); new Thread(runnable).start(); // creates one thread new Thread(runnable).start(); // creates second thread } // Inherited run method from the Runnable interface @Override public void run() { try { // Calling the non-synchronized method print()…

Read More Java Synchronized Blocks and Methods

class PrintArrayElementsExample { public static void main(String[] args) { int[] arr1 = {1, 7, 9, 5, 2, 8, 3}; String[] arr2 = {“Megan”, “Tom”, “Melissa”, “John”, “Steve”}; // print elements of the arr1 System.out.println(Arrays.toString(arr1)); // print elements of the arr2 System.out.println(Arrays.toString(arr2)); } } Output: [1, 7, 9, 5, 2, 8, 3] [Megan, Tom, Melissa, John,…

Read More Print Array Elements in Java

public class SplitString { public static void main(String[] args) { String names = “Tom,Steve,John,Megan,Melissa”; // split string String[] arr = names.split(“,”); // print the size of the array System.out.println(arr.length); // print the elements Stream.of(arr).forEach(System.out::println); } } Output: 5 Tom Steve John Megan Melissa   If you need a list, instead of an array, use the…

Read More Split a comma-separated String in Java

In this tutorial, you will learn how to implement the API Gateway Lambda Authorizer in Java. You will also learn how to make Lambda Authorizer validate Authorization JWT. First, we will create an API using API Gateway then we will make lambda function as an integration point for the GET method of our resource. After…

Read More API Gateway Lambda Authorizer Example in Java