Java Examples & Code Snippets | Java Code Geeks https://examples.javacodegeeks.com/ Java 2 Java Developers Resource Center Tue, 02 Apr 2024 11:04:38 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.1 https://examples.javacodegeeks.com/wp-content/uploads/2013/05/JavaCodeGeeks-favIcon.png Examples Java Code Geeks https://examples.javacodegeeks.com/ 32 32 How to Subscribe a Kafka Consumer to Multiple Topics https://examples.javacodegeeks.com/how-to-subscribe-a-kafka-consumer-to-multiple-topics/ https://examples.javacodegeeks.com/how-to-subscribe-a-kafka-consumer-to-multiple-topics/#respond <![CDATA[Omozegie Aziegbe]]> Tue, 02 Apr 2024 11:04:36 +0000 <![CDATA[Enterprise Java]]> <![CDATA[kafka]]> <![CDATA[Kafka Consumer]]> <![CDATA[Streaming Data]]> https://examples.javacodegeeks.com/?p=123189 <![CDATA[Apache Kafka is a leading distributed streaming platform that enables the building of real-time data pipelines and streaming applications. One of Kafka’s core components is its consumer API, which allows applications to subscribe to and process streams of records in real time. Handling data from multiple topics concurrently is a common requirement in many Kafka-based …]]> https://examples.javacodegeeks.com/how-to-subscribe-a-kafka-consumer-to-multiple-topics/feed/ 0 Construct HashMap from String https://examples.javacodegeeks.com/construct-hashmap-from-string/ https://examples.javacodegeeks.com/construct-hashmap-from-string/#respond <![CDATA[Ashraf Sarhan]]> Fri, 29 Mar 2024 13:14:37 +0000 <![CDATA[Core Java]]> <![CDATA[hashmap]]> https://examples.javacodegeeks.com/?p=122943 <![CDATA[1. Introduction Java’s HashMap class is a widely used data structure that stores key-value pairs. In this tutorial, we’ll aim to elucidate the process of constructing a HashMap from its String representation in Java, outlining both simple and complex conversion scenarios. 2. Unpacking HashMap String Representations When you call the toString() method on a HashMap …]]> https://examples.javacodegeeks.com/construct-hashmap-from-string/feed/ 0 Getting Record Fields and Values with Reflection https://examples.javacodegeeks.com/getting-record-fields-and-values-with-reflection/ https://examples.javacodegeeks.com/getting-record-fields-and-values-with-reflection/#comments <![CDATA[Ashraf Sarhan]]> Fri, 29 Mar 2024 13:12:36 +0000 <![CDATA[Core Java]]> <![CDATA[Java Records]]> <![CDATA[Reflection API]]> https://examples.javacodegeeks.com/?p=122951 <![CDATA[1. Overview In the ever-evolving landscape of Java programming, mastering reflection is a crucial skill. Reflection empowers developers to dynamically inspect and manipulate classes, interfaces, fields, and methods at runtime. With the introduction of records in Java 14, the need to efficiently retrieve record fields and their values has become increasingly important. In this comprehensive …]]> https://examples.javacodegeeks.com/getting-record-fields-and-values-with-reflection/feed/ 1 Remove Line Breaks from a File in Java https://examples.javacodegeeks.com/remove-line-breaks-from-a-file-in-java/ https://examples.javacodegeeks.com/remove-line-breaks-from-a-file-in-java/#respond <![CDATA[Omozegie Aziegbe]]> Wed, 27 Mar 2024 14:54:33 +0000 <![CDATA[Core Java]]> <![CDATA[Data manipulation]]> <![CDATA[File Operations]]> <![CDATA[Java File Handling]]> <![CDATA[Line Break Removal]]> <![CDATA[Text File Processing]]> https://examples.javacodegeeks.com/?p=123193 <![CDATA[Handling files is a common task, and sometimes it becomes necessary to manipulate the content within these files. One such operation is removing line breaks from a file. Line breaks can be in different formats such as '\n' (Unix/Linux), '\r\n' (Windows), or '\r' (older Macintosh systems). Line breaks create new lines in text files, sometimes …]]> https://examples.javacodegeeks.com/remove-line-breaks-from-a-file-in-java/feed/ 0 RSocket Interface in Spring https://examples.javacodegeeks.com/rsocket-interface-in-spring/ https://examples.javacodegeeks.com/rsocket-interface-in-spring/#respond <![CDATA[Yatin]]> Tue, 26 Mar 2024 14:28:00 +0000 <![CDATA[spring]]> <![CDATA[rsocket]]> https://examples.javacodegeeks.com/?p=123125 <![CDATA[RSocket in Spring Framework 6 offers a modern network communication protocol for building responsive, resilient, and message-driven applications. It supports bidirectional, multiplexed data streams over a single connection, facilitating efficient communication between microservices or server-client architectures, with enhanced throughput and reduced latency compared to traditional HTTP-based interactions. 1. Introduction The introduction of RSocket in Spring …]]> https://examples.javacodegeeks.com/rsocket-interface-in-spring/feed/ 0 Introduction to Apache Kafka https://examples.javacodegeeks.com/introduction-to-apache-kafka/ https://examples.javacodegeeks.com/introduction-to-apache-kafka/#respond <![CDATA[Yatin]]> Tue, 26 Mar 2024 13:27:57 +0000 <![CDATA[Enterprise Java]]> <![CDATA[apache kafka]]> <![CDATA[kafka]]> https://examples.javacodegeeks.com/?p=123121 <![CDATA[Apache Kafka provides a reliable, scalable, and fault-tolerant messaging system that enables the exchange of data streams between multiple applications and microservices. Let us delve into understanding Apache Kafka and its basics. 1. Introduction Apache Kafka is a distributed streaming platform. It is designed to handle real-time, high-throughput data feeds. Kafka provides a publish-subscribe model …]]> https://examples.javacodegeeks.com/introduction-to-apache-kafka/feed/ 0 Java 21: Unnamed Class & Instance Main https://examples.javacodegeeks.com/java-21-unnamed-class-instance-main/ https://examples.javacodegeeks.com/java-21-unnamed-class-instance-main/#respond <![CDATA[Yatin]]> Tue, 26 Mar 2024 08:43:00 +0000 <![CDATA[Core Java]]> <![CDATA[Java 21]]> https://examples.javacodegeeks.com/?p=123063 <![CDATA[Java 21 introduces unnamed classes and instance main methods, enhancing simplicity and flexibility. Unnamed classes allow for quick, on-the-fly class definitions without a formal name, streamlining test code, or one-off implementations. Instance main methods enable executing code within an instance’s context directly, facilitating more intuitive object-oriented programming practices. Let us delve into understanding Java 21 …]]> https://examples.javacodegeeks.com/java-21-unnamed-class-instance-main/feed/ 0 Convert Char Array to Int Array in Java https://examples.javacodegeeks.com/convert-char-array-to-int-array-in-java/ https://examples.javacodegeeks.com/convert-char-array-to-int-array-in-java/#respond <![CDATA[Omozegie Aziegbe]]> Mon, 25 Mar 2024 22:20:13 +0000 <![CDATA[Core Java]]> <![CDATA[ASCII values]]> <![CDATA[Character array]]> <![CDATA[Conversion techniques]]> <![CDATA[Data manipulation]]> <![CDATA[Integer array]]> <![CDATA[Java Programming]]> https://examples.javacodegeeks.com/?p=123191 <![CDATA[One common task we could encounter is converting character arrays to integer arrays. There are several ways to convert a character array containing digits (char[]) into an integer array (int[]) in Java. In this guide, we will explore different techniques to accomplish this task. 1. Using Character.getNumericValue() Java provides a built-in method Character.getNumericValue(char) that returns …]]> https://examples.javacodegeeks.com/convert-char-array-to-int-array-in-java/feed/ 0 Validate Boolean type in Spring Boot https://examples.javacodegeeks.com/validate-boolean-type-in-spring-boot/ https://examples.javacodegeeks.com/validate-boolean-type-in-spring-boot/#respond <![CDATA[Yatin]]> Mon, 25 Mar 2024 18:41:33 +0000 <![CDATA[spring]]> <![CDATA[boolean]]> <![CDATA[spring boot]]> https://examples.javacodegeeks.com/?p=123066 <![CDATA[In a Spring Boot application, validating the Boolean type ensures data integrity and application reliability. By enforcing constraints on Boolean inputs, such as true/false values, potential errors, and inconsistencies are minimized, contributing to robustness and accurate functionality within the system. Let us delve into a spring boot application example to understand the different ways to …]]> https://examples.javacodegeeks.com/validate-boolean-type-in-spring-boot/feed/ 0 Rotate Arrays in Java https://examples.javacodegeeks.com/rotate-arrays-in-java/ https://examples.javacodegeeks.com/rotate-arrays-in-java/#respond <![CDATA[Omozegie Aziegbe]]> Mon, 25 Mar 2024 12:14:00 +0000 <![CDATA[Core Java]]> <![CDATA[algorithms]]> <![CDATA[Array Rotation]]> <![CDATA[arrays]]> <![CDATA[data structures]]> <![CDATA[Java]]> https://examples.javacodegeeks.com/?p=123077 <![CDATA[In Java, array rotation refers to shifting the elements of an array by a specified number of positions. This operation can be performed in either direction: clockwise (right rotation) or counter-clockwise (left rotation). Array rotation finds applications in various domains such as algorithm design, data manipulation, and cryptography. This article will explore different approaches to …]]> https://examples.javacodegeeks.com/rotate-arrays-in-java/feed/ 0