🌐
GeeksforGeeks
geeksforgeeks.org › java › java-programming-examples
Java Programs - Java Programming Examples - GeeksforGeeks
September 2, 2026 - A collection of Java programming examples covering a wide range of topics, from basic programs and pattern printing to arrays, strings, collections, file handling, exception handling, and multithreading.
Discussions

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
Where can I read well written Java code?
That is a lousy professor. You want to learn more? Nope, don't think so. You could find open source projects that are written in java. Or maybe check out the source code for OpenJDK (library implementation). But better yet, pick up a book. You have the popular book Clean Code by R. C. Martin that covers how to write clean and maintainable code. Or maybe the book Head first: Design Patterns by that covers common designs used to make adaptable and reusable code. But your professor has one point. You should not get lost into code design when still learning the basics. So remember to focus on what you learn in class! :) More on reddit.com
🌐 r/learnjava
10
10
March 15, 2014
🌐
W3Schools
w3schools.com › java › java_examples.asp
Java Examples
Browse Java examples for every topic - syntax, variables, data types, loops, classes, and more.
🌐
Tpoint Tech
tpointtech.com › java-programs
Java Programs | Java Programming Examples - Tpoint Tech
February 10, 2026 - These programs demonstrate pattern printing using loops and basic control statements. Java program to print the following spiral pattern on the console
🌐
Tutorial Gateway
tutorialgateway.org › learn-java-programs
Java Program Examples
July 21, 2026 - This article shows the list of Java one-dimensional array programs and the 2-D matrix programs with examples.
🌐
PW Skills
pwskills.com › blog › java › basic-java-program-examples
35 Basic Java Program Examples with Outputs | Simple Java Program
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.
🌐
University of Texas
cs.utexas.edu › ~scottm › cs307 › codingSamples.htm
Java Coding Samples
UnsortedSetTest - A method to compare Java's TreeSet and HashSet to the BianrySearchTree, UnsortedSet, and UnsortedHashSet classes developed in class. Note you need a lot of other files for this to work. SimpleWordCount - Program demonstrating use of a map to count the frequency of words in a file.
🌐
BeginnersBook
beginnersbook.com › 2017 › 09 › java-examples
Java Programs – Java Programming Examples with Output
Write java program to find if a name exists in a list of names.The program should display how many times the name occurs in the list.The program should have at least two instance methods. ... Hi where can i get real time example programs such as 1 find out the no of persons in a room 2 Find the electricity bill for one month
Find elsewhere
🌐
Edureka
edureka.co › blog › java-programs
Best Java Programs for Practice: Beginners and Experienced
February 13, 2025 - This Java program reverses letters present in the string entered by a user. For example, Hello People will be termed as olleH elpoeP.
🌐
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.
🌐
CodeScracker
codescracker.com › java › program › java-programming-examples.htm
Java Programming Examples
Java Programming Examples with Output: I've written around 500 Java codes here, separated into more than 100 Java program articles.
🌐
WsCube Tech
wscubetech.com › resources › java › programs
Java Programs (Code Examples With Output)
Practising small examples strengthens logic, improves problem-solving, and prepares you for coding rounds, interviews, and real-world Java development. Whether you want to learn basics or solve advanced logic-building problems, this page gives you a complete collection of Java programs with explanations and outputs.
🌐
TutorialsPoint
tutorialspoint.com › javaexamples › index.htm
Java Programming Examples
Here are most commonly used examples − · How to sort an array and search an element inside it? How to sort an array and insert an element inside it? How to determine the upper bound of a two dimentional array? ... Learn how to play with data and time in Java programming.
🌐
Simplilearn
simplilearn.com › home › resources › software development › best java programs for practice: beginner and experienced examples
Best Java Programs for Practice: Beginner and Experienced Examples
July 8, 2026 - Practice top Java programs for beginners and experts. Explore hands-on coding examples to master loops, arrays, OOP, and real-world Java concepts.
Address: 5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
HowToDoInJava
howtodoinjava.com › home › java examples › java examples
Java Programming Examples for Practice - HowToDoInJava
December 25, 2020 - To learn Java or any other programming language, the only best way is to practice and practice more. The more you do the coding, the better you get as time passes. These listed Java examples cover some very basic Java fundamentals and present you few alternative solutions to …
🌐
Karanartscollege
karanartscollege.edu.in › assets › images › ebook › 100+ Java Programs with Output_ Useful collection of Java Programs ( PDFDrive ).pdf pdf
100+ Java Programs with Output
Scanner class to get input from user. This program firstly asks the user to enter a string · and then the string is printed, then an integer and entered integer is also printed and finally · a float and it is also printed on the screen. Scanner class is present in java.util package so
🌐
YouTube
youtube.com › watch
Simple java program examples for beginners | Hello world java code | Start Programming with Java - YouTube
Simple java program examples for beginners and Hello world java code and Start Programming with JavaComputer Education for all provides In this Tutorial abou...
Published: July 31, 2017
🌐
Nevolearn
nevolearn.com › home › blog › simple java code for beginners
Simple Java Code for Beginners: Learn to Code with Basic Examples.
May 12, 2026 - Here’s a basic Java code example showcasing OOP principles: ... Class: Car is a class with three attributes: make, model, and year. Object: We create an object car from the Car class.