🌐
GeeksforGeeks
geeksforgeeks.org › java › java-programming-examples
Java Programs - Java Programming Examples - GeeksforGeeks
September 25, 2025 - This page covers Java programming examples from basics like Fibonacci, Prime numbers, Factorials and Palindromes to advanced topics such as Arrays, Strings and OOP concepts.
Discussions

Example Of A Java Program From A Working Developer?
For enterprise applications, it's very layered. You have the Controller layer, the Service layer, and the DAO layer to name a few. Heavy use of interfaces and REST APIs. Enterprise applications are usually built on a framework (eg. Spring), whether it's Java or any other language. Dependencies are managed with something like Maven. Applications are run on multiple servers using a load balancer to improve performance. More on reddit.com
🌐 r/learnjava
10
63
September 27, 2021
What are your favorite examples of "good code"?
Nothing comes close to guava in quality. More on reddit.com
🌐 r/java
12
19
May 7, 2015
Java basics with examples
Why not just ask here what you're having trouble with? Let's have a crack, shall we? This is a class: public class Demo { } There is nothing in it (well, there is... it actually looks like this) public class Demo { public Demo(){ super(); } } Which is to say that in Java, when you write the Demo code I initially wrote, the compiler sneakily makes a method called Demo, with a method call of super(). It won't do this if you make your own constructor, but let's not focus on that - let's ask why the compiler would be so sneaky. A class is a blueprint in java, but it's not very useful on it's own - it needs to be "instantiated". In the same way that a factory might have a blueprint for a tank. Blueprints for tanks aren't very useful on their own - ask the Polish military during WW2 about how that panned out*. What is useful is a tank - but note you cannot make a tank without a blueprint. Ok, so if a class is the blueprint, what is, to continue the analogy, the outcome of the blueprint? Well, that's called an object. An object is to a class, as a tank is to a blueprint. Now in the factory, you make a tank by turning the machine on. In java, it's a little different - each class has it's own "on" switch. It would be better to think of the analogy as a spell in a spell book. The spell in written form isn't going to blow up a house. But incant the spell and kaboom! So a class is like a spell - abracadabra. And an object is the bolt of lightning that jumps forth. Which is all a long way of saying that the sneaky code Java adds is like when you read the spell. In fact, that code is a method, and a particular method - it's called a constructor. So now we have the constructor, (which is a method) and the end result is an object (which is a class made "real"). A useful class will define things - it's state. Like this: class Person { int age; } (Yes, java will also add a constructor, identical to the earlier one, but this one will be called "Person"). When you want to make this Person "real" you call that constructor. But how? You use the "new" method. So you would write Person peter = new Person(); Now you have made a Person. Saying "new Person()" is like reading the incantation. The... magic that makes that into an object is in the constructor that Java adds. If Person then has another method called, uh, "sayHello()" then you would call it like this: peter.sayHello(); //good boy Peter! Is this... useful? *I don't actually know if that story about the Polish with the cardboard tanks is real or not, one images it was grossly exaggerated. But it's a nice teaching image, right? More on reddit.com
🌐 r/learnjava
8
9
June 15, 2018
Professional Java code examples?

Look at the source code of some of the apache projects like apache commons. It's source can be browsed online.

More on reddit.com
🌐 r/learnprogramming
1
1
September 22, 2014
🌐
W3Schools
w3schools.com › java › java_examples.asp
Java Examples
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
Edureka
edureka.co › blog › java-programs
Best Java Programs for Practice: Beginners and Experienced
February 13, 2025 - On executing the above program, you will get factorial of a number as shown below: Enter the number: 12 Factorial of entered number is: 47900160 · It is a series in which the next term is the sum of the preceding two terms. For Example: 0 1 1 2 3 5 8 13……. Let’s write a Java program to calculate the Fibonacci series.
🌐
University of Texas
cs.utexas.edu › ~scottm › cs307 › codingSamples.htm
Java Coding Samples
A Hello World! Java program. Calling Methods. A sample of how to call methods in the same class. For loop. A simple example of using for loops to calculate factorial.
🌐
Tutorial Gateway
tutorialgateway.org › learn-java-programs
Java Program Examples
February 7, 2025 - It is a high-level object-oriented programming language that runs on various platforms, including Windows, mac os, Unix, etc. For all these simple and basic Java programs, we provide multiple examples (ways to find the solution) using for loop, while loop, do while, recursion, functions, and the compiled code result.
Find elsewhere
🌐
PW Skills
pwskills.com › blog › java › basic-java-program-examples
35 Basic Java Program Examples with Outputs | Simple Java Program
October 30, 2025 - Basic/Simple Java Program Examples include simple tasks like printing messages, using loops, conditionals, and arithmetic operations. These examples help beginners understand Java’s syntax and logic flow, providing a strong foundation for developing real-world applications.
🌐
IBM
ibm.com › docs › en › i › 7.4.0
Java Code examples
The following is a list of Java code examples for the IBM i.
🌐
Sanfoundry
sanfoundry.com › java-programming-examples
Java Programming Examples - Sanfoundry
October 9, 2023 - These Java programming examples are categorized as basic, array, numbers, math functions, string, classes, inheritance, event handling, exception handling, collections, methods, java applets, searching, Sorting, etc.
🌐
Princeton CS
introcs.cs.princeton.edu › java › 11hello
1.1 Your First Java Program: Hello World
June 10, 2022 - Modify UseArgument.java to make a program UseThree.java that takes three names and prints out a proper sentence with the names in the reverse of the order given, so that for example, "java UseThree Alice Bob Carol" gives "Hi Carol, Bob, and Alice.".
🌐
TutorialsPoint
tutorialspoint.com › java › index.htm
Java Tutorial
You can edit and run almost all the examples directly from your browser without the need to set up your development environment. Try to click the icon to run the following Java code to print conventional "Hello, World!" using Java Programming.
🌐
W3Schools
w3schools.com › java › java_syntax.asp
Java Syntax
In our example, we named the class Main. Note: Java is case-sensitive. MyClass and myclass would be treated as two completely different names. The name of the Java file must match the class name. So if your class is called Main, the file must be saved as Main.java. This is because Java uses the class name to find and run your code. If the names don't match, Java will give an error and the program will not run.
🌐
YouTube
youtube.com › playlist
Java Example Programs with Explanation for Beginners - YouTube
Here we have the Java Programming language example programs which will help you to learn the Java language for beginners.
🌐
Computer Science Circles
cscircles.cemc.uwaterloo.ca › java_visualize
Java Visualizer
How can I access Java's built-in Stack/Queue instead of the introcs one? At the top of your program, write import java.util.Stack; — note, import java.util.*; won't work. How do I get shorter URLs? For example code, you can use #sampleFile=ExecLimit but in general, this is a feature that ...
🌐
HackerRank
hackerrank.com › domains › java
Solve Programming Questions | HackerRank
Java (Intermediate) Problem Solving (Intermediate) Difficulty · Easy · Medium · Hard · Subdomains · Introduction · Strings · BigNumber · Data Structures · Object Oriented Programming · Exception Handling ·
🌐
W3Schools
w3schools.in › java › examples
Java Programming Examples Index
The best way to learn Java is by practicing examples. This page has lots of examples of Java programming. You are advised to look at these examples and try them yourself.
🌐
freeCodeCamp
freecodecamp.org › news › hello-world-in-java-example-program
Hello World in Java – Example Program
June 7, 2022 - To create a class, you use the class keyword, followed by the name of the class. Here's an example using our Hello World program: ... Every Java program must have a main method.
🌐
Codecademy
codecademy.com › learn › learn-java
Java Tutorial: Learn Java Programming | Codecademy
Let's take a closer look at the Hello World program — line by line! ... Learn essential Java coding style rules with the Java style guide, including naming conventions, brackets, spacing, and indentation best practices.
Rating: 4.4 ​ - ​ 10.8K votes