java

Let’s build “Java demos” together during Hacktoberfest

Let’s build “Java demos” together during Hacktoberfest

Last year I first learned about Hacktoberfest where devs are encouraged to contribute into open-source projects. I managed to pass the challenge, although I spent a lot of time going through many projects from first class global tools (where I didn't see how to contribute) to totally meaningless "Hello, Worlds" (where I didn't see why to contribute). In 2024, I am looking for struggle through this once again. But this time, I also wanted to place something on the other pan of the scale. I am working here and there on number of different side projects in my GitHub repo.…
Read More
Collections.nCopies method in Java

Collections.nCopies method in Java

For Explanation watch video The Collections.nCopies method in Java is used to create an immutable list consisting of the same object repeated a specified number of times. This method is part of the java.util.Collections class. public static <T> List<T> nCopies(int n, T o) Enter fullscreen mode Exit fullscreen mode Parametersn: The number of times to repeat the object in the list.o: The object to be repeated in the list. Return ValueThe method returns an immutable list containing n copies of the specified object. Key Points The list returned is immutable, meaning you cannot modify it (e.g., you cannot add or…
Read More
Introducing JDK 23: Java Developer’s Ultimate Upgrade with Advanced AI Enhancements

Introducing JDK 23: Java Developer’s Ultimate Upgrade with Advanced AI Enhancements

Oracle is proud to announce the general availability of JDK 23, a major update to the Java Development Kit with advanced capabilities for the development of cloud-native applications and machine learning. This release builds on Java's three-decade legacy, offering new features and thousands of updates to improve performance, stability, and security. With this release, developers can take advantage of 12 new JDK Enhancement Proposals (JEPs) and enhancements in areas such as concurrency, memory management, and language simplicity. These updates aim to maintain Java's position as one of the most popular and widely-used programming languages in the world, while also meeting…
Read More
Collections.min() method in Java

Collections.min() method in Java

For More info watch video The Collections.min method is a part of the Java Collections Framework and is used to find the minimum element in a given collection. It utilizes the natural ordering of the elements (if they implement the Comparable interface) or a specified Comparator to determine the minimum element. Description of Collections.minMethod SignaturesNatural Ordering public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> coll) Enter fullscreen mode Exit fullscreen mode Parameters:coll: The collection from which the minimum element is to be determined. All elements in the collection must implement the Comparable interface.Returns: The minimum…
Read More
Why is 1 == 1 is true but 1000 == 1000 is false When dealing with Wrapper Classes in Java?

Why is 1 == 1 is true but 1000 == 1000 is false When dealing with Wrapper Classes in Java?

In Java, the behavior where 1 == 1 is true but 1000 == 1000 is false when dealing with wrapper classes can be surprising. This is due to how Java handles object comparison and the concept of object caching for certain values in wrapper classes.Understanding Wrapper Classes: Java has wrapper classes for primitive types (e.g., Integer for int, Double for double, etc.). These wrapper classes allow primitive types to be treated as objects, which is useful in situations where an object is required, like in collections. Autoboxing: When you compare two numbers using == and these numbers are of primitive…
Read More
Spring Boot: A Revolução no Desenvolvimento de Aplicações Java

Spring Boot: A Revolução no Desenvolvimento de Aplicações Java

Se você desenvolve em Java, já deve ter ouvido falar de Spring Boot. Mas se ainda não conhece, prepare-se para descobrir uma das ferramentas mais poderosas e práticas que revolucionou o jeito de criar aplicações Java! O que é o Spring Boot? O Spring Boot é um framework que facilita (e muito!) o desenvolvimento de aplicativos Java. Ele tira de você aquela dor de cabeça de configurar tudo manualmente, como banco de dados, segurança, APIs, entre outras coisas. Com ele, você pode criar rapidamente uma aplicação pronta para rodar, com pouquíssimas linhas de código e quase nenhuma configuração. Por que…
Read More
Enhance Your Spring Boot Skills by Solving Exception Handling Issues: Implement a Global Handler for UserNotFoundException

Enhance Your Spring Boot Skills by Solving Exception Handling Issues: Implement a Global Handler for UserNotFoundException

Overview This implementation enhances the exception handling mechanism within the Journal REST API application by defining a custom exception, UserNotFoundException, and implementing a global exception handler to manage this exception effectively. The goal is to centralize exception handling, improving code maintainability and consistency. Got to Issue Tasks 1. Define UserNotFoundException Create a custom exception class named UserNotFoundException. 2. Implement Global Exception Handler Implement a global exception handler to manage the UserNotFoundException. 3. Refactor Existing Code Refactor the existing controller code to remove local handling of UserNotFoundException. How to Contribute Fork the repository: Journal-Rest-API Clone the repository: git clone https://github.com/yourusername/Journal-Rest-API.git cd…
Read More
The persistent threat: Why major vulnerabilities like Log4Shell and Spring4Shell remain significant

The persistent threat: Why major vulnerabilities like Log4Shell and Spring4Shell remain significant

As developers, we're constantly juggling features, fixes, and deadlines. Yet, a lurking issue has been surprisingly overlooked: the continued use of vulnerable Log4j and Spring Framework versions in many projects. Despite the high-profile exposure of Log4Shell and Spring4Shell vulnerabilities, a shocking number of applications are still running on these ticking time bombs. This isn't just a minor oversight — it's a major risk. We're builders at heart, but part of building is ensuring our structures are safe.  The developer’s dilemma As developers, we constantly balance pushing out new features and maintaining the existing projects and features. It's a balancing act…
Read More
Item 49: Verifique a validade dos parâmetros

Item 49: Verifique a validade dos parâmetros

Capítulo: Design de Métodos Foco: Usabilidade, robustez e flexibilidade no design de métodos. Cobertura: Tratamento de parâmetros e valores de retorno, design de assinaturas de métodos e documentação. Item 49: Verifique a Validade dos Parâmetros - Restrições em Parâmetros: Métodos e construtores geralmente possuem restrições sobre os valores dos parâmetros (ex.: índices não negativos, referências não nulas). Essas restrições devem ser documentadas e verificadas no início do método. - Importância da Verificação: Detectar erros o mais cedo possível para evitar falhas inesperadas ou comportamento incorreto no método. Métodos que não verificam seus parâmetros podem causar falhas difíceis de depurar. -…
Read More
Eager vs Lazy Initialization of Spring Beans

Eager vs Lazy Initialization of Spring Beans

In Spring, one of the fundamental concepts revolves around the initialization of beans. When developing applications using the Spring Framework, you have the option to choose between eager and lazy initialization of beans. Both have their unique advantages and trade-offs, and understanding these differences can help you optimize your application’s performance and resource usage. What are Spring Beans? Before diving into eager and lazy initialization, let’s briefly touch on what Spring beans are. In Spring, a bean is simply an object that is instantiated, assembled, and managed by the Spring IoC (Inversion of Control) container. Beans are typically singleton by…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.