/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,553 Subscribers

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?

1 Comment
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

0

Automatic AI-Based Java Unit Test Generation - Best Practices Guide

The guide below shows how automated java unit testing offers a variety of benefits that enhance the quality of software development. It also explains the best practices such as designing testable code, prioritizing test cases, and maintaining a clean codebase: Best Practices in Automatic Java Unit Test Generation

0 Comments
2023/07/31
05:55 UTC

2

Deploy Secure Spring Boot Microservices on Amazon EKS Using Terraform and Kubernetes

Deploy a cloud-native Java Spring Boot microservice stack secured with Auth0 on Amazon EKS using Terraform and Kubernetes.
Read more…

0 Comments
2023/07/18
21:27 UTC

1

Get started with Spring Boot and Auth0

Learn how to add Auth0 to your Spring Boot application using the Okta Spring Boot Starter.
Read more…

0 Comments
2023/06/27
19:57 UTC

12

Website with Java examples

Hello everyone,

I am a software developer with several years of experience. As my side project and hobby I created a website with Java tutorials. If you are interested, please visit: https://simplecoding.net/

This project has the sole purpose of showing some examples of Java programs.

I will be happy if you manage to learn something from it :)

Have a nice day!

2 Comments
2023/03/18
17:01 UTC

4

JavaFX FXML tutorial for beginners

Screen recording about the FXML language for JavaFX https://www.youtube.com/watch?v=kL-Q_H250Fc

1 Comment
2023/03/13
09:11 UTC

1

REST to gRPC | Suggestions

I have taken it upon my self to migrate a Micro-Service I look after to gRPC. My manager is open to the idea of experimentation.

After doing a lot of research and learning basics about it, first thing which is preventing me from going ahead is there is no official library/project from spring from this. All I have found over and over again are reference to this github project [GitHub - yidongnan/grpc-spring-boot-starter: Spring Boot starter module for gRPC framework.] which seem fairly active.

I am fairly new as SE with only one 1 YOE. I have few concerns though. First one being is it a good idea to use aforementioned project for production? If so are there any articles/guides/case studies that you would like to refer?

I am open to honest thoughts, suggestions and criticism. FYI, org I work in is industry leading and gets massive traffic. However, Mircro-Service I am working on can handle 5-10 minutes of downtime as worse without really impacting business because of the fallbacks.

1 Comment
2023/03/04
05:05 UTC

2

Java CountDownLatch Example for Beginners - [Multithreading Tutorial]

0 Comments
2023/02/18
14:52 UTC

2

25 Examples of ConcurrentHashMap in Java

0 Comments
2023/02/08
13:21 UTC

1

11 Examples of LocalDate, LocalTime, and LocalDateTime in Java 8

0 Comments
2023/02/05
13:03 UTC

1

3 Examples of Anonymous Class to Learn Lambda Expression better in Java 8

0 Comments
2023/01/31
02:49 UTC

1

Map.compute(), computeIfPresent() and ComputeIfAbsent Example in Java

0 Comments
2023/01/28
04:56 UTC

3

Decompile Java JAR using JD-GUI tutorial for beginners

Screen recording about how to use the JD-GUI Java decompiler https://www.youtube.com/watch?v=HXgZZz3M3sQ

1 Comment
2023/01/07
15:28 UTC

1

How to write to a File with try-with-resource in Java? Example Tutorial

0 Comments
2023/01/07
08:31 UTC

Back To Top