/r/javaexamples
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:
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
How to Properly Compare Strings in Java
Reading and Parsing Data from a File
/r/javaexamples
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
Deploy a cloud-native Java Spring Boot microservice stack secured with Auth0 on Azure AKS using Terraform and Kubernetes.
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
I wrote an article about iterating over a Map in Java - https://javarevisited.blogspot.com/2011/12/how-to-traverse-or-loop-hashmap-in-java.html
I wrote an article of 10 ways to use Stream in Java https://javarevisited.blogspot.com/2024/08/top-12-java-8-stream-examples-for.html
How to add Fine-Grained Authorization (FGA) to a Spring Boot API using the OpenFGA Spring Boot starter.
I wrote an article about sorting using Comparator and thenComparing() method https://javarevisited.blogspot.com/2021/09/comparator-comparing-thenComparing-example-java-.html
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
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
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
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
A whilst stop tour of Weblog Analyser built using Java with JavaFX as a desktop application.
Implementing OpenID Connect authentication in Java Web Applications with Okta Spring Boot Starter and Spring Security support for Authorization Code Flow with PKCE
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…
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
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?
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.
A walk-through of building a microservices architecture with JHipster, Keycloak, Auth0, and Google Kubernetes Engine (GKE) deployment.
Read more…
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
This tutorial shows you how to build a microservices architecture with Spring Boot and Spring Cloud.
Read more…
Abstract factory design pattern in java complete step by step tutorial
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!
A step-by-step guide for building a secured GraphQL API with Spring Boot and Auth0 authentication in React
Read more…
A step-by-step guide for building a secured GraphQL API with Spring Boot and Auth0 authentication in React
Read more…
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."
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.
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
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
so to practice dsa , which platform is best ?
im beginner 2nd yr in my btech, so
leetcode or codechef or gfg or ??
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!