Running on Java 21-ea+24-2086 (Preview)
Home of The JavaSpecialists' Newsletter

1.4 Buffer Overflows

Juppies 2 by Dr Heinz M. Kabutz

We learn how the game rolls around once we get to the end of the words, by using the remainder function %. Let's say we have 10 words. We always start at index 0 and go up to index 9. When we then add one to the index we get 10, but the remainder of dividing 10 by 10 is 0. This is a neat trick to go from 0 to 9, then back to 0, up to 9, back to 0, ad nauseam.

In Java if we try read past the end of an array, we get an ArrayIndexOutOfBoundsException. In a language like C, we might end up in program code. We call this a buffer overflow. Hackers use these all the time to insert malicious code into systems. Java fortunately won't allow such mischief.


When you load these comments, you'll be connected to Disqus. Privacy Statement.

Table of Contents

We hope you enjoyed this tutorial. If you did, you will also enjoy our courses. We suggest you start with Extreme Java - Advanced Java, followed by Extreme Java - Concurrency Performance for Java 8.

About the Author

Heinz Kabutz Java Conference Speaker

Java Champion, author of the Javaspecialists Newsletter, conference speaking regular... About Heinz

Superpack '23

Superpack '23 Our entire Java Specialists Training in one huge bundle more...

Free Java Book

Dynamic Proxies in Java Book
Java Training

We deliver relevant courses, by top Java developers to produce more resourceful and efficient programmers within their organisations.

Java Consulting

We can help make your Java application run faster and trouble-shoot concurrency and performance bugs...

Java Emergency?

If your system is down, we will review it for 15 minutes and give you our findings for just 1 € without any obligation.