Merge branch 'master' of https://github.com/eugenp/tutorials into BAEL-17473
This commit is contained in:
commit
4f22a71702
|
@ -1,3 +1,8 @@
|
|||
## Algorithms - Miscellaneous
|
||||
|
||||
This module contains articles about algorithms. Some classes of algorithms, e.g., [sorting](/algorithms-sorting) and
|
||||
[genetic algorithms](/algorithms-genetic), have their own dedicated modules.
|
||||
|
||||
## Relevant Articles:
|
||||
|
||||
- [Java Two Pointer Technique](https://www.baeldung.com/java-two-pointer-technique)
|
||||
|
@ -9,3 +14,4 @@
|
|||
- [A Guide to the Folding Technique in Java](https://www.baeldung.com/folding-hashing-technique)
|
||||
- [Creating a Triangle with for Loops in Java](https://www.baeldung.com/java-print-triangle)
|
||||
- [Efficient Word Frequency Calculator in Java](https://www.baeldung.com/java-word-frequency)
|
||||
- More articles: [[<-- prev]](/algorithms-miscellaneous-2) [[next -->]](/algorithms-miscellaneous-4)
|
|
@ -1,4 +1,8 @@
|
|||
## Relevant articles:
|
||||
## Algorithms - Sorting
|
||||
|
||||
This module contains articles about sorting algorithms.
|
||||
|
||||
### Relevant articles:
|
||||
|
||||
- [Bubble Sort in Java](https://www.baeldung.com/java-bubble-sort)
|
||||
- [Merge Sort in Java](https://www.baeldung.com/java-merge-sort)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Relevant articles:
|
||||
## Animal Sniffer Maven Plugin
|
||||
|
||||
This module contains articles about the Animal Sniffer Maven Plugin
|
||||
|
||||
### Relevant articles:
|
||||
|
||||
[Introduction to Animal Sniffer Maven Plugin](https://www.baeldung.com/maven-animal-sniffer)
|
||||
|
|
|
@ -1,2 +1,7 @@
|
|||
## Annotations
|
||||
|
||||
This module contains articles about Java annotations
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Java Annotation Processing and Creating a Builder](https://www.baeldung.com/java-annotation-processing-builder)
|
|
@ -1,3 +1,7 @@
|
|||
## ANTLR
|
||||
|
||||
This module contains articles about ANTLR
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Java with ANTLR](https://www.baeldung.com/java-antlr)
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
## Apache Avro
|
||||
|
||||
This module contains articles about Apache Avro
|
||||
|
||||
### Relevant Articles:
|
||||
- [Guide to Apache Avro](https://www.baeldung.com/java-apache-avro)
|
||||
|
|
|
@ -1,2 +1,7 @@
|
|||
## Apache BVal
|
||||
|
||||
This module contains articles about Apache BVal
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Intro to Apache BVal](https://www.baeldung.com/apache-bval)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Apache Curator
|
||||
|
||||
This module contains articles about Apache Curator
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Introduction to Apache Curator](https://www.baeldung.com/apache-curator)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Apache CXF
|
||||
|
||||
This module contains articles about Apache CXF
|
||||
|
||||
## Relevant Articles:
|
||||
- [Introduction to Apache CXF Aegis Data Binding](https://www.baeldung.com/aegis-data-binding-in-apache-cxf)
|
||||
- [Apache CXF Support for RESTful Web Services](https://www.baeldung.com/apache-cxf-rest-api)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
=========
|
||||
## Apache FOP
|
||||
|
||||
## Core Java Cookbooks and Examples
|
||||
This module contains articles about Apache FOP
|
||||
|
||||
### Relevant Articles:
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Apache Geode
|
||||
|
||||
This module contains articles about Apache Geode
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [A Quick Guide to Apache Geode](https://www.baeldung.com/apache-geode)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Apache Meecrowave
|
||||
|
||||
This module contains articles about Apache Meecrowave
|
||||
|
||||
### Relevant Articles:
|
||||
================================
|
||||
|
||||
- [Building a Microservice with Apache Meecrowave](https://www.baeldung.com/apache-meecrowave)
|
|
@ -1,4 +1,8 @@
|
|||
## Relevant articles:
|
||||
## Apache Olingo
|
||||
|
||||
This module contains articles about Apache Olingo
|
||||
|
||||
### Relevant articles:
|
||||
|
||||
- [OData Protocol Guide](https://www.baeldung.com/odata)
|
||||
- [Intro to OData with Olingo](https://www.baeldung.com/olingo)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Apache OpenNLP
|
||||
|
||||
This module contains articles about Apache OpenNLP
|
||||
|
||||
### Relevant Articles
|
||||
|
||||
- [Intro to Apache OpenNLP](https://www.baeldung.com/apache-open-nlp)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Apache POI
|
||||
|
||||
This module contains articles about Apache POI
|
||||
|
||||
### Relevant Articles:
|
||||
- [Microsoft Word Processing in Java with Apache POI](https://www.baeldung.com/java-microsoft-word-with-apache-poi)
|
||||
- [Working with Microsoft Excel in Java](https://www.baeldung.com/java-microsoft-excel)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Apache Pulsar
|
||||
|
||||
This module contains articles about Apache Pulsar
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Introduction to Apache Pulsar](https://www.baeldung.com/apache-pulsar)
|
||||
|
|
|
@ -1,2 +1,7 @@
|
|||
### Relevant articles
|
||||
## Apache Shiro
|
||||
|
||||
This module contains articles about Apache Shiro
|
||||
|
||||
### Relevant articles:
|
||||
|
||||
- [Introduction to Apache Shiro](https://www.baeldung.com/apache-shiro)
|
|
@ -1,4 +1,7 @@
|
|||
## Apache Solrj Tutorials Project
|
||||
## Apache Solrj
|
||||
|
||||
This module contains articles about Apache Solrj
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
### Relevant Articles
|
||||
- [Guide to Solr in Java with Apache Solrj](https://www.baeldung.com/apache-solrj)
|
|
@ -1,4 +1,8 @@
|
|||
### Relevant articles
|
||||
## Apache Spark
|
||||
|
||||
This module contains articles about Apache Spark
|
||||
|
||||
### Relevant articles:
|
||||
|
||||
- [Introduction to Apache Spark](https://www.baeldung.com/apache-spark)
|
||||
- [Building a Data Pipeline with Kafka, Spark Streaming and Cassandra](https://www.baeldung.com/kafka-spark-data-pipeline)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Relevant articles:
|
||||
## Apache Thrift
|
||||
|
||||
This module contains articles about Apache Thrift
|
||||
|
||||
### Relevant articles:
|
||||
|
||||
- [Working with Apache Thrift](https://www.baeldung.com/apache-thrift)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Relevant articles:
|
||||
## Apache Tika
|
||||
|
||||
This module contains articles about Apache Tika
|
||||
|
||||
### Relevant articles:
|
||||
|
||||
- [Content Analysis with Apache Tika](https://www.baeldung.com/apache-tika)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Relevant articles:
|
||||
## Apache Velocity
|
||||
|
||||
This module contains articles about Apache Velocity
|
||||
|
||||
### Relevant articles:
|
||||
|
||||
- [Introduction to Apache Velocity](https://www.baeldung.com/apache-velocity)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Relevant articles:
|
||||
## Apache Zookeeper
|
||||
|
||||
This module contains articles about Apache Zookeeper
|
||||
|
||||
### Relevant articles:
|
||||
|
||||
- [Getting Started with Java and Zookeeper](https://www.baeldung.com/java-zookeeper)
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
### Relevant articles
|
||||
## Asciidoctor
|
||||
|
||||
This module contains articles about Asciidoctor
|
||||
|
||||
### Relevant articles:
|
||||
|
||||
- [Generating a Book with Asciidoctor](https://www.baeldung.com/asciidoctor-book)
|
||||
- [Introduction to Asciidoctor in Java](https://www.baeldung.com/asciidoctor)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## ASM
|
||||
|
||||
This module contains articles about ASM
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [A Guide to Java Bytecode Manipulation with ASM](https://www.baeldung.com/java-asm)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Relevant articles:
|
||||
## Atomix
|
||||
|
||||
This module contains articles about Atomix
|
||||
|
||||
### Relevant articles:
|
||||
|
||||
- [Introduction to Atomix](https://www.baeldung.com/atomix)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## AWS Lambda
|
||||
|
||||
This module contains articles about AWS Lambda
|
||||
|
||||
### Relevant Articles:
|
||||
- [Using AWS Lambda with API Gateway](https://www.baeldung.com/aws-lambda-api-gateway)
|
||||
- [Introduction to AWS Serverless Application Model](https://www.baeldung.com/aws-serverless)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## AWS
|
||||
|
||||
This module contains articles about AWS
|
||||
|
||||
### Relevant articles
|
||||
|
||||
- [AWS Lambda Using DynamoDB With Java](https://www.baeldung.com/aws-lambda-dynamodb-java)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Axon
|
||||
|
||||
This module contains articles about Axon
|
||||
|
||||
### Relevant articles
|
||||
|
||||
- [A Guide to the Axon Framework](https://www.baeldung.com/axon-cqrs-event-sourcing)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Azure
|
||||
|
||||
This module contains articles about Azure
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Deploy a Spring Boot App to Azure](https://www.baeldung.com/spring-boot-azure)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Relevant Articles:
|
||||
## Bazel
|
||||
|
||||
This module contains articles about Bazel
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Building Java Applications with Bazel](https://www.baeldung.com/bazel-build-tool)
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
## Bootique
|
||||
|
||||
This module contains articles about Bootique
|
||||
|
||||
### Relevant Articles:
|
||||
- [Introduction to Bootique](https://www.baeldung.com/bootique)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
## CAS
|
||||
|
||||
This module contains articles about the Central Authentication Service (CAS)
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [CAS SSO With Spring Security](baeldung.com/spring-security-cas-sso)
|
|
@ -1,3 +1,7 @@
|
|||
## CDI
|
||||
|
||||
This module contains articles about Contexts and Dependency Injection (CDI)
|
||||
|
||||
### Relevant Articles:
|
||||
- [CDI Interceptor vs Spring AspectJ](https://www.baeldung.com/cdi-interceptor-vs-spring-aspectj)
|
||||
- [An Introduction to CDI (Contexts and Dependency Injection) in Java](https://www.baeldung.com/java-ee-cdi)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Checker Plugin
|
||||
|
||||
This module contains articles about the Checker Plugin
|
||||
|
||||
### Relevant articles
|
||||
|
||||
- [The Checker Framework – Pluggable Type Systems for Java](https://www.baeldung.com/checker-framework)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
### Revelant Articles
|
||||
## Cloud Foundry UAA
|
||||
|
||||
This module contains articles about Cloud Foundry UAA
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [A Quick Guide To Using Cloud Foundry UAA](https://www.baeldung.com/cloud-foundry-uaa)
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
## Code Generation
|
||||
|
||||
This module contains articles about automatic code generation
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Introduction to AutoValue](https://www.baeldung.com/introduction-to-autovalue)
|
||||
- [Introduction to AutoFactory](https://www.baeldung.com/autofactory)
|
||||
- [Google AutoService](https://www.baeldung.com/google-autoservice)
|
|
@ -2,9 +2,9 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>autovalue</artifactId>
|
||||
<artifactId>code-generation</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>autovalue</name>
|
||||
<name>code-generation</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
|
@ -1,4 +1,6 @@
|
|||
# Groovy
|
||||
# Core Groovy 2
|
||||
|
||||
This module contains articles about core Groovy concepts
|
||||
|
||||
## Relevant articles:
|
||||
|
||||
|
@ -9,3 +11,4 @@
|
|||
- [Integrating Groovy into Java Applications](https://www.baeldung.com/groovy-java-applications)
|
||||
- [Concatenate Strings with Groovy](https://www.baeldung.com/groovy-concatenate-strings)
|
||||
- [Metaprogramming in Groovy](https://www.baeldung.com/groovy-metaprogramming)
|
||||
- [[<-- Prev]](/core-groovy)
|
|
@ -1,4 +1,6 @@
|
|||
# Groovy
|
||||
## Core Groovy Collections
|
||||
|
||||
This module contains articles about Groovy core collections
|
||||
|
||||
## Relevant articles:
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
# Groovy
|
||||
# Core Groovy
|
||||
|
||||
This module contains articles about core Groovy concepts
|
||||
|
||||
## Relevant articles:
|
||||
|
||||
|
@ -13,3 +15,4 @@
|
|||
- [Lists in Groovy](https://www.baeldung.com/groovy-lists)
|
||||
- [Converting a String to a Date in Groovy](https://www.baeldung.com/groovy-string-to-date)
|
||||
- [Guide to I/O in Groovy](https://www.baeldung.com/groovy-io)
|
||||
- [[More -->]](/core-groovy-2)
|
|
@ -1,3 +1,7 @@
|
|||
## Core Java Modules
|
||||
|
||||
This module contains modules about core Java
|
||||
|
||||
## Relevant articles:
|
||||
|
||||
- [Multi-Module Maven Application with Java Modules](https://www.baeldung.com/maven-multi-module-project-java-jpms)
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
## Core Java 10
|
||||
|
||||
This module contains articles about Java 10 core features
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Core Java 11
|
||||
|
||||
This module contains articles about Java 11 core features
|
||||
|
||||
### Relevant articles
|
||||
|
||||
- [Java 11 Single File Source Code](https://www.baeldung.com/java-single-file-source-code)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=========
|
||||
## Core Java 8 (part 2)
|
||||
|
||||
## Core Java 8 Cookbooks and Examples (part 2)
|
||||
This module contains articles about Java 8 core features
|
||||
|
||||
### Relevant Articles:
|
||||
- [Anonymous Classes in Java](http://www.baeldung.com/)
|
||||
|
@ -8,3 +8,4 @@
|
|||
- [Run a Java Application from the Command Line](https://www.baeldung.com/java-run-jar-with-arguments)
|
||||
- [Java 8 Stream skip() vs limit()](https://www.baeldung.com/java-stream-skip-vs-limit)
|
||||
- [Guide to Java BiFunction Interface](https://www.baeldung.com/java-bifunction-interface)
|
||||
- [[<-- Prev]](/core-java-modules/core-java-8)
|
|
@ -1,6 +1,6 @@
|
|||
=========
|
||||
## Core Java 8
|
||||
|
||||
## Core Java 8 Cookbooks and Examples
|
||||
This module contains articles about Java 8 core features
|
||||
|
||||
### Relevant Articles:
|
||||
- [New Features in Java 8](https://www.baeldung.com/java-8-new-features)
|
||||
|
@ -12,3 +12,4 @@
|
|||
- [Finding Min/Max in an Array with Java](https://www.baeldung.com/java-array-min-max)
|
||||
- [Internationalization and Localization in Java 8](https://www.baeldung.com/java-8-localization)
|
||||
- [Generalized Target-Type Inference in Java](https://www.baeldung.com/java-generalized-target-type-inference)
|
||||
- [[More -->]](/core-java-modules/core-java-8-2)
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
=========
|
||||
## Core Java 9
|
||||
|
||||
## Core Java 9 Examples
|
||||
|
||||
[Java 9 New Features](http://www.baeldung.com/new-java-9)
|
||||
This module contains articles about Java 9 core features
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## Core Java Arrays (Part 2)
|
||||
|
||||
This module contains articles about Java arrays
|
||||
|
||||
## Relevant Articles
|
||||
|
||||
- [Extending an Array’s Length](https://www.baeldung.com/java-array-add-element-at-the-end)
|
||||
|
@ -8,3 +12,4 @@
|
|||
- [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection)
|
||||
- [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element)
|
||||
- [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element)
|
||||
- [[<-- Prev]](/core-java-modules/core-java-arrays)
|
|
@ -1,6 +1,6 @@
|
|||
=========
|
||||
## Core Java Arrays
|
||||
|
||||
## Core Java Arrays Cookbooks and Examples
|
||||
This module contains articles about Java arrays
|
||||
|
||||
### Relevant Articles:
|
||||
- [How to Copy an Array in Java](https://www.baeldung.com/java-array-copy)
|
||||
|
@ -14,3 +14,4 @@
|
|||
- [How to Reverse an Array in Java](http://www.baeldung.com/java-invert-array)
|
||||
- [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays)
|
||||
- [Checking If an Array Is Sorted in Java](https://www.baeldung.com/java-check-sorted-array)
|
||||
- [[More -->]](/core-java-modules/core-java-arrays-2)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=========
|
||||
## Core Java Collections ArrayList
|
||||
|
||||
## Core Java Collections Array List Cookbooks and Examples
|
||||
This module contains articles about the Java ArrayList collection
|
||||
|
||||
### Relevant Articles:
|
||||
- [Immutable ArrayList in Java](http://www.baeldung.com/java-immutable-list)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=========
|
||||
## Core Java Collections List (Part 2)
|
||||
|
||||
## Core Java Collections List Cookbooks and Examples
|
||||
This module contains articles about the Java List collection
|
||||
|
||||
### Relevant Articles:
|
||||
- [Check If Two Lists are Equal in Java](http://www.baeldung.com/java-test-a-list-for-ordinality-and-equality)
|
||||
|
@ -11,3 +11,4 @@
|
|||
- [Ways to Iterate Over a List in Java](https://www.baeldung.com/java-iterate-list)
|
||||
- [Flattening Nested Collections in Java](http://www.baeldung.com/java-flatten-nested-collections)
|
||||
- [Intersection of Two Lists in Java](https://www.baeldung.com/java-lists-intersection)
|
||||
- [[<-- Prev]](/core-java-modules/core-java-collections-list)[[Next -->]](/core-java-modules/core-java-collections-list-3)
|
|
@ -1,6 +1,6 @@
|
|||
=========
|
||||
## Core Java Collections List (Part 3)
|
||||
|
||||
## Core Java Collections List Cookbooks and Examples
|
||||
This module contains articles about the Java List collection
|
||||
|
||||
### Relevant Articles:
|
||||
- [Collections.emptyList() vs. New List Instance](https://www.baeldung.com/java-collections-emptylist-new-list)
|
||||
|
@ -9,3 +9,4 @@
|
|||
- [List of Primitive Integer Values in Java](https://www.baeldung.com/java-list-primitive-int)
|
||||
- [Performance Comparison of Primitive Lists in Java](https://www.baeldung.com/java-list-primitive-performance)
|
||||
- [Filtering a Java Collection by a List](https://www.baeldung.com/java-filter-collection-by-list)
|
||||
- [[<-- Prev]](/core-java-modules/core-java-collections-list-2)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=========
|
||||
## Core Java Collections List
|
||||
|
||||
## Core Java Collections List Cookbooks and Examples
|
||||
This module contains articles about the Java List collection
|
||||
|
||||
### Relevant Articles:
|
||||
- [Java – Get Random Item/Element From a List](http://www.baeldung.com/java-random-list-element)
|
||||
|
@ -12,3 +12,4 @@
|
|||
- [How to Find an Element in a List with Java](http://www.baeldung.com/find-list-element-java)
|
||||
- [Finding Max/Min of a List or Collection](http://www.baeldung.com/java-collection-min-max)
|
||||
- [Remove All Occurrences of a Specific Value from a List](https://www.baeldung.com/java-remove-value-from-list)
|
||||
- [[Next -->]](/core-java-modules/core-java-collections-list-2)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=========
|
||||
## Core Java Collections Set
|
||||
|
||||
## Core Java Sets Cookbooks and Examples
|
||||
This module contains articles about the Java Set collection
|
||||
|
||||
### Relevant Articles:
|
||||
- [Set Operations in Java](http://www.baeldung.com/set-operations-in-java)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=========
|
||||
## Core Java Collections
|
||||
|
||||
## Core Java Collections Cookbooks and Examples
|
||||
This module contains articles about Java collections
|
||||
|
||||
### Relevant Articles:
|
||||
- [Collect a Java Stream to an Immutable Collection](https://www.baeldung.com/java-stream-immutable-collection)
|
||||
|
@ -13,3 +13,4 @@
|
|||
- [Defining a Char Stack in Java](https://www.baeldung.com/java-char-stack)
|
||||
- [Guide to the Java Queue Interface](https://www.baeldung.com/java-queue)
|
||||
- [An Introduction to Synchronized Java Collections](https://www.baeldung.com/java-synchronized-collections)
|
||||
- [[More -->]](/core-java-modules/core-java-collections-2)
|
|
@ -1,7 +1,7 @@
|
|||
=========
|
||||
|
||||
## Core Java Concurrency Advanced Examples
|
||||
|
||||
This module contains articles about advanced concurrency in core Java.
|
||||
|
||||
### Relevant Articles:
|
||||
- [Introduction to Thread Pools in Java](http://www.baeldung.com/thread-pool-java-and-guava)
|
||||
- [Guide to CountDownLatch in Java](http://www.baeldung.com/java-countdown-latch)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=========
|
||||
## Core Java Concurrency Basic
|
||||
|
||||
## Core Java Concurrency Basic Examples
|
||||
This module contains articles about basic Java concurrency
|
||||
|
||||
### Relevant Articles:
|
||||
- [Guide To CompletableFuture](https://www.baeldung.com/java-completablefuture)
|
||||
|
@ -13,3 +13,4 @@
|
|||
- [Runnable vs. Callable in Java](https://www.baeldung.com/java-runnable-callable)
|
||||
- [What is Thread-Safety and How to Achieve it?](https://www.baeldung.com/java-thread-safety)
|
||||
- [How to Start a Thread in Java](https://www.baeldung.com/java-start-thread)
|
||||
- [[Next -->]](/core-java-modules/core-java-concurrency-basic-2)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=========
|
||||
## Core Java Concurrency Collections
|
||||
|
||||
## Core Java Concurrency Collections Examples
|
||||
This module contains articles about concurrent Java collections
|
||||
|
||||
### Relevant Articles:
|
||||
- [Guide to java.util.concurrent.BlockingQueue](http://www.baeldung.com/java-blocking-queue)
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
## Relevant Articles:
|
||||
## Core Java Exceptions
|
||||
|
||||
- [Will an Error Be Caught by Catch Block in Java?](https://www.baeldung.com/java-error-catch)
|
||||
- [Java Global Exception Handler](http://www.baeldung.com/java-global-exception-handler)
|
||||
- [Common Java Exceptions](http://www.baeldung.com/java-common-exceptions)
|
||||
- [Throw Exception in Optional in Java 8](https://www.baeldung.com/java-optional-throw-exception)
|
||||
- [How to Find an Exception’s Root Cause in Java](https://www.baeldung.com/java-exception-root-cause)
|
||||
- [Java – Try with Resources](https://www.baeldung.com/java-try-with-resources)
|
||||
This module contains articles about core java exceptions
|
||||
|
||||
### Relevant articles:
|
||||
- [Chained Exceptions in Java](https://www.baeldung.com/java-chained-exceptions)
|
||||
- [ClassNotFoundException vs NoClassDefFoundError](https://www.baeldung.com/java-classnotfoundexception-and-noclassdeffounderror)
|
||||
- [Create a Custom Exception in Java](https://www.baeldung.com/java-new-custom-exception)
|
||||
- [Exception Handling in Java](https://www.baeldung.com/java-exceptions)
|
||||
- [Differences Between Final, Finally and Finalize in Java](https://www.baeldung.com/java-final-finally-finalize)
|
||||
- [Difference Between Throw and Throws in Java](https://www.baeldung.com/java-throw-throws)
|
||||
- [“Sneaky Throws” in Java](https://www.baeldung.com/java-sneaky-throws)
|
||||
- [The StackOverflowError in Java](https://www.baeldung.com/java-stack-overflow-error)
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<groupId>com.baeldung.exceptions</groupId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.exception.numberformat</groupId>
|
||||
<artifactId>core-java-exceptions</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-exceptions</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
|
@ -16,25 +18,15 @@
|
|||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>${javax.mail.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-core</artifactId>
|
||||
<version>${jmh-core.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-generator-annprocess</artifactId>
|
||||
<version>${jmh-generator-annprocess.version}</version>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- test scoped -->
|
||||
<dependency>
|
||||
|
@ -46,10 +38,9 @@
|
|||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<commons-lang3.version>3.9</commons-lang3.version>
|
||||
<jmh-core.version>1.19</jmh-core.version>
|
||||
<javax.mail.version>1.5.0-b01</javax.mail.version>
|
||||
<!-- testing -->
|
||||
<assertj-core.version>3.10.0</assertj-core.version>
|
||||
<jmh-generator-annprocess.version>1.19</jmh-generator-annprocess.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -1,20 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Arithmetic {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(Arithmetic.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
int result = 30 / 0; // Trying to divide by zero
|
||||
} catch (ArithmeticException e) {
|
||||
LOGGER.error("ArithmeticException caught!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ArrayIndexOutOfBounds {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(ArrayIndexOutOfBounds.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
int[] nums = new int[] { 1, 2, 3 };
|
||||
|
||||
try {
|
||||
int numFromNegativeIndex = nums[-1]; // Trying to access at negative index
|
||||
int numFromGreaterIndex = nums[4]; // Trying to access at greater index
|
||||
int numFromLengthIndex = nums[3]; // Trying to access at index equal to size of the array
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
LOGGER.error("ArrayIndexOutOfBoundsException caught");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
public class CheckedUncheckedExceptions {
|
||||
public static void checkedExceptionWithThrows() throws FileNotFoundException {
|
||||
File file = new File("not_existing_file.txt");
|
||||
FileInputStream stream = new FileInputStream(file);
|
||||
}
|
||||
|
||||
public static void checkedExceptionWithTryCatch() {
|
||||
File file = new File("not_existing_file.txt");
|
||||
try {
|
||||
FileInputStream stream = new FileInputStream(file);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int divideByZero() {
|
||||
int numerator = 1;
|
||||
int denominator = 0;
|
||||
return numerator / denominator;
|
||||
}
|
||||
|
||||
public static void checkFile(String fileName) throws IncorrectFileNameException {
|
||||
if (fileName == null || fileName.isEmpty()) {
|
||||
throw new NullOrEmptyException("The filename is null.");
|
||||
}
|
||||
if (!isCorrectFileName(fileName)) {
|
||||
throw new IncorrectFileNameException("Incorrect filename : " + fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isCorrectFileName(String fileName) {
|
||||
if (fileName.equals("wrongFileName.txt"))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
class Animal {
|
||||
|
||||
}
|
||||
|
||||
class Dog extends Animal {
|
||||
|
||||
}
|
||||
|
||||
class Lion extends Animal {
|
||||
|
||||
}
|
||||
|
||||
public class ClassCast {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(ClassCast.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
Animal animalOne = new Dog(); // At runtime the instance is dog
|
||||
Dog bruno = (Dog) animalOne; // Downcasting
|
||||
|
||||
Animal animalTwo = new Lion(); // At runtime the instance is animal
|
||||
Dog tommy = (Dog) animalTwo; // Downcasting
|
||||
} catch (ClassCastException e) {
|
||||
LOGGER.error("ClassCastException caught!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class FileNotFound {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(FileNotFound.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(new File("/invalid/file/location")));
|
||||
} catch (FileNotFoundException e) {
|
||||
LOGGER.error("FileNotFoundException caught!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Handler globalExceptionHandler = new Handler();
|
||||
Thread.setDefaultUncaughtExceptionHandler(globalExceptionHandler);
|
||||
new GlobalExceptionHandler().performArithmeticOperation(10, 0);
|
||||
}
|
||||
|
||||
public int performArithmeticOperation(int num1, int num2) {
|
||||
return num1/num2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Handler implements Thread.UncaughtExceptionHandler {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(Handler.class);
|
||||
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
LOGGER.info("Unhandled exception caught!");
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class IllegalArgument {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(IllegalArgument.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
Thread.sleep(-1000);
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.error("IllegalArgumentException caught!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class IllegalState {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(IllegalState.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
List<Integer> intList = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
intList.add(i);
|
||||
}
|
||||
|
||||
Iterator<Integer> intListIterator = intList.iterator(); // Initialized with index at -1
|
||||
|
||||
try {
|
||||
intListIterator.remove(); // IllegalStateException
|
||||
} catch (IllegalStateException e) {
|
||||
LOGGER.error("IllegalStateException caught!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
public class IncorrectFileNameException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public IncorrectFileNameException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
|
||||
public IncorrectFileNameException(String errorMessage, Throwable thr) {
|
||||
super(errorMessage, thr);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
class ChildThread extends Thread {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(ChildThread.class);
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.error("InterruptedException caught!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class InterruptedExceptionExample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
ChildThread childThread = new ChildThread();
|
||||
childThread.start();
|
||||
childThread.interrupt();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class MalformedURL {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(MalformedURL.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
URL baeldungURL = null;
|
||||
|
||||
try {
|
||||
baeldungURL = new URL("malformedurl");
|
||||
} catch (MalformedURLException e) {
|
||||
LOGGER.error("MalformedURLException caught!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
public class NullOrEmptyException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NullOrEmptyException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
|
||||
public NullOrEmptyException(String errorMessage, Throwable thr) {
|
||||
super(errorMessage, thr);
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class NullPointer {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(NullPointer.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Person personObj = null;
|
||||
|
||||
try {
|
||||
String name = personObj.personName; // Accessing the field of a null object
|
||||
personObj.personName = "Jon Doe"; // Modifying the field of a null object
|
||||
} catch (NullPointerException e) {
|
||||
LOGGER.error("NullPointerException caught!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class Person {
|
||||
|
||||
public String personName;
|
||||
|
||||
public String getPersonName() {
|
||||
return personName;
|
||||
}
|
||||
|
||||
public void setPersonName(String personName) {
|
||||
this.personName = personName;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class NumberFormat {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(NumberFormat.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String str1 = "100ABCD";
|
||||
|
||||
try {
|
||||
int x = Integer.parseInt(str1); // Converting string with inappropriate format
|
||||
int y = Integer.valueOf(str1);
|
||||
} catch (NumberFormatException e) {
|
||||
LOGGER.error("NumberFormatException caught!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ParseExceptionExample {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(ParseExceptionExample.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
DateFormat format = new SimpleDateFormat("MM, dd, yyyy");
|
||||
|
||||
try {
|
||||
format.parse("01, , 2010");
|
||||
} catch (ParseException e) {
|
||||
LOGGER.error("ParseException caught!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Utility class to find root cause exceptions.
|
||||
*/
|
||||
public class RootCauseFinder {
|
||||
|
||||
private RootCauseFinder() {
|
||||
}
|
||||
|
||||
public static Throwable findCauseUsingPlainJava(Throwable throwable) {
|
||||
Objects.requireNonNull(throwable);
|
||||
Throwable rootCause = throwable;
|
||||
while (rootCause.getCause() != null && rootCause.getCause() != rootCause) {
|
||||
rootCause = rootCause.getCause();
|
||||
}
|
||||
return rootCause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the age of a person from a given date.
|
||||
*/
|
||||
static class AgeCalculator {
|
||||
|
||||
private AgeCalculator() {
|
||||
}
|
||||
|
||||
public static int calculateAge(String birthDate) {
|
||||
if (birthDate == null || birthDate.isEmpty()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
try {
|
||||
return Period
|
||||
.between(parseDate(birthDate), LocalDate.now())
|
||||
.getYears();
|
||||
} catch (DateParseException ex) {
|
||||
throw new CalculationException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static LocalDate parseDate(String birthDateAsString) {
|
||||
|
||||
LocalDate birthDate;
|
||||
try {
|
||||
birthDate = LocalDate.parse(birthDateAsString);
|
||||
} catch (DateTimeParseException ex) {
|
||||
throw new InvalidFormatException(birthDateAsString, ex);
|
||||
}
|
||||
|
||||
if (birthDate.isAfter(LocalDate.now())) {
|
||||
throw new DateOutOfRangeException(birthDateAsString);
|
||||
}
|
||||
|
||||
return birthDate;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class CalculationException extends RuntimeException {
|
||||
|
||||
CalculationException(DateParseException ex) {
|
||||
super(ex);
|
||||
}
|
||||
}
|
||||
|
||||
static class DateParseException extends RuntimeException {
|
||||
|
||||
DateParseException(String input) {
|
||||
super(input);
|
||||
}
|
||||
|
||||
DateParseException(String input, Throwable thr) {
|
||||
super(input, thr);
|
||||
}
|
||||
}
|
||||
|
||||
static class InvalidFormatException extends DateParseException {
|
||||
|
||||
InvalidFormatException(String input, Throwable thr) {
|
||||
super("Invalid date format: " + input, thr);
|
||||
}
|
||||
}
|
||||
|
||||
static class DateOutOfRangeException extends DateParseException {
|
||||
|
||||
DateOutOfRangeException(String date) {
|
||||
super("Date out of range: " + date);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
public class StackTraceToString {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Convert a StackTrace to String using core java
|
||||
try {
|
||||
throw new NullPointerException();
|
||||
} catch (Exception e) {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
e.printStackTrace(pw);
|
||||
|
||||
System.out.println(sw.toString());
|
||||
}
|
||||
|
||||
// Convert a StackTrace to String using Apache Commons
|
||||
try {
|
||||
throw new IndexOutOfBoundsException();
|
||||
} catch (Exception e) {
|
||||
System.out.println(ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package com.baeldung.exceptions;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class StringIndexOutOfBounds {
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(StringIndexOutOfBounds.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String str = "Hello World";
|
||||
|
||||
try {
|
||||
char charAtNegativeIndex = str.charAt(-1); // Trying to access at negative index
|
||||
char charAtLengthIndex = str.charAt(11); // Trying to access at index equal to size of the string
|
||||
} catch (StringIndexOutOfBoundsException e) {
|
||||
LOGGER.error("StringIndexOutOfBoundsException caught");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue