/r/javaexamples

Photograph via snooOG

Simple Java Programming examples, tutorial code, algorithms etc.

This subreddit is for example code for algorithms, common beginning programmer problems, helpful snippets etc.

Please try to: Make your code clean and readable and commented where necessary. Make sure it works!

Note on link-based posts: Posts that link to a blog or website need to follow the following rules:

  1. No spam
  2. Any link to a blog with popups or excessive advertising will be removed
  3. Must be original content and no overt attempts to monetize

This sub is not for asking Java questions, please submit those to /r/JavaHelp or /r/learnprogramming

As posts get added I will add them to the sidebar.

DIRECT LINKS

Using Comparator to Sort a List of Objects

Getting Input from the Console : Validating and Looping

A Quick Explanation of Loops

How to Properly Compare Strings in Java

Reading and Parsing Data from a File

Writing and Appending Data to a Text File

Sorted Doubly-Linked List

Generic Undirected Graph with Depth-First Search

/r/javaexamples

3,573 Subscribers

0

Object Oriented Programming Example in Java

Here is a simple example in Java to understand the object oriented programming better:

https://javarevisited.blogspot.com/2010/10/fundamentals-of-object-oriented.html

1 Comment
2024/09/16
14:09 UTC

1

Deploy Secure Spring Boot Microservices on Azure AKS Using Terraform and Kubernetes

Deploy a cloud-native Java Spring Boot microservice stack secured with Auth0 on Azure AKS using Terraform and Kubernetes.

Read more…

0 Comments
2024/09/06
14:45 UTC

0

7 best practices Java developers can follow while dealing with passwords

I wrote an article about best practices Java developers can follow while dealing with passwords or sensitive information in Java application - https://javarevisited.blogspot.com/2012/05/best-practices-while-dealing-with.html

0 Comments
2024/09/06
10:03 UTC

3

4 ways to iterate over Map in Java

0 Comments
2024/09/04
14:36 UTC

3

10 ways to use Stream in Java

0 Comments
2024/09/03
13:50 UTC

2

OpenFGA for Spring Boot applications

How to add Fine-Grained Authorization (FGA) to a Spring Boot API using the OpenFGA Spring Boot starter.

Read more…

0 Comments
2024/09/02
15:29 UTC

1

Sorting in Java using Comparator and thenComparing() method

I wrote an article about sorting using Comparator and thenComparing() method https://javarevisited.blogspot.com/2021/09/comparator-comparing-thenComparing-example-java-.html

0 Comments
2024/09/02
13:44 UTC

2

Connect to Minio from Java.

Minio is an open source object storage similar to S3. This article explains how to connect to Minio from Java.

https://www.blackslate.io/articles/connect-to-minio-from-java

0 Comments
2024/08/30
07:09 UTC

3

10 Examples of ArrayList in Java

ArrayList is an important class and every Java developer should be aware of. Here are 10 examples of ArrayList in Java to learn this class better https://javarevisited.blogspot.com/2011/05/example-of-arraylist-in-java-tutorial.html

0 Comments
2024/08/28
13:14 UTC

3

3 ways to parse JSON in Java?

You got a JSON string from API and want to parse? Well, there are many options in Java, from simply getting key value to converting it into an object, I have shared 3 of most common of them using Jackson, Gson and Json simple

https://javarevisited.blogspot.com/2022/03/3-examples-to-parse-json-in-java-using.html

0 Comments
2024/08/27
13:28 UTC

8

10 Examples of using HashMap in Java

HashMap is an important class and every Java dev should be aware of it. Here are 10 examples of using HashMap in Java:

https://www.java67.com/2013/02/10-examples-of-hashmap-in-java-programming-tutorial.html

0 Comments
2024/08/25
04:26 UTC

1

Showcase Weblog Analyser Java Desktop Application

A whilst stop tour of Weblog Analyser built using Java with JavaFX as a desktop application.

https://youtu.be/-98ZEiDRo6w

0 Comments
2024/08/17
11:08 UTC

2

Proof Key for Code Exchange (PKCE) in Web Applications with Spring Security

Implementing OpenID Connect authentication in Java Web Applications with Okta Spring Boot Starter and Spring Security support for Authorization Code Flow with PKCE

Read more…

0 Comments
2024/06/13
21:00 UTC

1

Add Security and Authorization to a Java Spring Boot API

Learn how to use Spring Boot, Java, and Auth0 to secure a feature-complete API by implementing authorization in Spring Boot with Auth0.
Read more…

0 Comments
2024/04/12
21:43 UTC

1

Generating Tests for Spring and Extending Existing Test Suite for Java with Codium AI - video tutorial

This video shows how CodiumAI can extend the existing test suite for a Spring-based Java application. In this video we explore a couple of different ways to add tests to an existing codebase - focusing more on generating new tests based off of existing tests - and showcasing the different capabilities of CodiumAI’s IntelliJ plugin (also works on VS Code), including test analysis, behavior coverage analysis, and test generation: Generating Tests For Spring And Extending Existing Test Suite For Java - Codium AI

0 Comments
2024/01/09
17:58 UTC

2

Use cases of interface and abstract class after jdk1.8

Hi , I tried to dig up little bit more about the use cases of interface and abstract class. Since jdk1.8, it is really difficult to understand when one should use abstract class and when one should be using interface.

Can somebody please share any examples or documents to get the actual scenarios?

2 Comments
2024/01/06
17:01 UTC

1

No body in method in class files

Hi, While traversing through code, I came across one class where the constructor and method bodies have this , /* Compiled code*/ in intellij idea. This is not the case with other team members system. I tried to cross verify the settings in the intellij but couldn't get anything which could solve my issue. Project is Spring MVC project. Using Jdk1.8 . Intelliij is Ultimate 2023 latest version.

0 Comments
2024/01/04
13:16 UTC

1

Identity in Spring Boot with Kubernetes, Keycloak, and Auth0

A walk-through of building a microservices architecture with JHipster, Keycloak, Auth0, and Google Kubernetes Engine (GKE) deployment.
Read more…

0 Comments
2023/12/13
15:17 UTC

1

Troubleshooting StackOverflowException in Java Recursion: Tips and Tricks

What should you do when your recursive algorithm reaches the recursion limit in a specified JVM target, resulting in a StackOverflowException?🤔
Join us in the latest episode of 'Java Puzzle of the Week' 🧩 as we delve into four possible solutions to tackle this issue.
https://youtu.be/muwv8l4-aWg?si=Jy1JPj7chitvyUKe

0 Comments
2023/11/24
07:42 UTC

2

Java Microservices with Spring Boot and Spring Cloud

This tutorial shows you how to build a microservices architecture with Spring Boot and Spring Cloud.
Read more…

0 Comments
2023/11/13
14:26 UTC

1

Abstract factory design pattern in java

Abstract factory design pattern in java complete step by step tutorial

https://youtu.be/u3LuF3t6rp0

0 Comments
2023/11/11
10:28 UTC

1

Double arithmetic

Explore the intricacies of Java doubles in the latest episode of 'Java Puzzle of the Week.' 🧩🔍 We delve into their internals and discuss why they might not be the best choice for financial operations. Don't miss this intriguing exploration!

https://youtu.be/TOhMzfnVO0E?si=832dLcO1BCa70B0\_

0 Comments
2023/11/03
11:59 UTC

1

How to Build a GraphQL API with Spring Boot

A step-by-step guide for building a secured GraphQL API with Spring Boot and Auth0 authentication in React
Read more…

0 Comments
2023/10/31
19:54 UTC

1

How to Build a GraphQL API with Spring Boot

A step-by-step guide for building a secured GraphQL API with Spring Boot and Auth0 authentication in React
Read more…

0 Comments
2023/10/31
19:54 UTC

1

String uppercase

Did you know that string transformations like toUpperCase and toLowerCase can work differently for different locales and may even affect the length of a given string? Discover more insights in the latest episode of "Java Puzzle of the Week."

https://youtu.be/2483FxiAQvw?si=HjYH3WIMmE1Sx34l

0 Comments
2023/10/26
13:07 UTC

1

Numeric overflow in Java

Numeric overflow occurs when the value of a numeric type exceeds its defined range, often leading to unexpected and potentially problematic outcomes. For a clear and concise explanation, I prepared a short YouTube video on this topic.

https://youtu.be/5vfTm-rJLds?si=hZ1La6s3VyglDJNq

0 Comments
2023/10/18
08:37 UTC

1

Java heap pollution

Have you heard about Java heap pollution? 🚀 It's an intriguing issue in the world of Java programming. If you're curious to learn more, check out the latest episode of 'Java Puzzle of the Week' 🧩 where we explore this topic. Your thoughts and insights are welcome!
https://www.youtube.com/watch?v=-PXkz8MzCp0

0 Comments
2023/10/05
13:07 UTC

0

Integer ABS - Programming Puzzle of the week

The calculation of absolute value is a basic arithmetic operation. In the latest episode of Java Puzzle of the Week 🧩, we are checking if it can be calculated correctly for every value of the Integer type.

https://www.youtube.com/watch?v=ET8jSVskBWM&list=PL8NC5lCgGs6MTxHSPdqpAjtXhs66cZgRL

0 Comments
2023/09/30
06:43 UTC

1

dsa preparation problesm

so to practice dsa , which platform is best ?

im beginner 2nd yr in my btech, so

leetcode or codechef or gfg or ??

0 Comments
2023/09/20
12:28 UTC

1

A simple Java integer comparison - Programming Puzzle of the Week

Hello, I've started contributing to a new YouTube series called "Java Puzzle of the Week." 🧩
In this series, I'll delve into short Java code snippets with varying levels of difficulty. 🤓
The first episode tackles integer comparisons. New episodes will appear at every Thursday.

If you're interested, I'd love for you to check it out!

https://www.youtube.com/watch?v=TmuoAo7CkM4

0 Comments
2023/09/07
15:24 UTC

Back To Top