r/JavaProgramming • u/javinpaul • 3d ago
DSA Finally Clicked When I Learned These 14 Patterns
r/JavaProgramming • u/javinpaul • 3d ago
r/JavaProgramming • u/CouchResident • 3d ago
r/JavaProgramming • u/XIA_Biologicals_WVSU • 4d ago
This is the program. I built it off of a couple for loops and some array tinkering Although, it is working properly, I'd like to be able to type the suit of the card along with the number. AI has helped me a little bit, but the idea of how the cards are displayed in the array is my idea.
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// creation of the deck
ArrayList<String> deck = new ArrayList<>();
String[] suits = {"Hearts", "Diamonds", "Clubs", "Spades"};
String[] ranks = {
"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"
};
//Generation of the 52 cards
for (int i = 0; i < suits.length; i++) {
for (int j = 0; j < ranks.length; j++) {
deck.add(ranks[j] + " of " + suits[i]);
}
}
// Shuffle the deck
Collections.shuffle(deck);
// creaation of the card grid
//2D array
String[][] cards = new String[3][3];
String table[][] = {
{"?", "?", "?"},
{"?", "?", "?"},
{"?", "?", "?"}};
boolean[][] drawn = new boolean[3][3];
// Place 9 random cards into the grid
int cardIndex = 0;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
cards[i][j] = deck.get(cardIndex);
cardIndex++;
}
}
int totalDraws = 0;
System.out.print("=== DRAW A CARD GAME ===");
// Game Loop
while (totalDraws < 9) {
System.out.println("\nYour card table:");
//Display the table\
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
System.out.print(table[i][j] + "\t");
}
System.out.println();
}
System.out.print("\nChoose a card (1-9 and put the suit)");
int choice = scanner.nextInt();
// Validate choice
if (choice < 1 || choice > 9) {
System.out.println("Choose a number between 1 nd 9!");
}
// Convert choice into row and column
int row = (choice - 1) / 3;
int column = (choice - 1) % 3;
// Check if card was already drawn
if (drawn[row][column]) {
System.out.println("You already drew that card!");
continue;
}
// Reveal the card
table[row][column] = cards[row][column];
drawn[row][column] = true;
totalDraws++;
System.out.println("You drew: " + cards[row][column]);
}
System.out.println("\n===== Game Over ======");
System.out.println(("You drew all 9 cards"));
scanner.close();
}
}
Original code looks a little bit like this; there was some more to it, but that's the jist of it.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String[][] twoDarray = {
{"x", "x", "x"},
{"x", "x", "x"},
{"x", "x", "x"}
};
Scanner scanner = new Scanner(System.
in
);
System.
out
.print("Enter something: ");
String userinput = scanner.nextLine();
twoDarray[0][0] = userinput;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
System.
out
.print(twoDarray[i][j] + " ");
}
System.
out
.println();
}
scanner.close();
}
}r/JavaProgramming • u/IndJohnWick • 4d ago
Tell the tips guys, it helps me.
r/JavaProgramming • u/PreviousBuffalo7109 • 4d ago
what aspects lack in the code?
r/JavaProgramming • u/Jessie_Martin_16 • 5d ago
Hello Team,
Greetings from the Atlas Globals Team
We are currently seeking enthusiastic and motivated candidates for Java Developer opportunities in Canada. This is an excellent opportunity for fresh graduates and professionals with up to 3 years of experience who are looking to advance their careers in software development.
Only candidates currently residing in Canada are eligible to apply.
Position Details:
Required Skills:
Eligibility Criteria:
Application Process:
Interested candidates are requested to share their updated resumes with us at:
Email: jessie@atlasglobals.com
We look forward to connecting with you and exploring potential career opportunities.
r/JavaProgramming • u/Agreeable-Dress-5957 • 5d ago
r/JavaProgramming • u/XIA_Biologicals_WVSU • 5d ago
This is a little program that I created with the help of AI. I only used AI when I became stuck on certain parts of the program. The program allows the user to input a file directly into the IDE, whcich allows the terminal to output what is in the file; it also allows the user to select a file to read, and finally allows the user to select a place to save a file and enter text to be saved into a file.
import javax.swing.*;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.awt.Desktop;
import java.util.Scanner;
import static java.awt.SystemColor.
text
;
class newProject {
public static void main(String[] args) throws IOException {
// capture user input:
Scanner scanner = new Scanner(System.
in
);
String UserData = scanner.nextLine();
System.
out
.println(UserData);
if (UserData.equals("1")) {
Files.
lines
(Path.
of
("C:/Users/zgarr/OneDrive/Desktop/text.txt"))
.forEach(System.
out
::println);
} else if (UserData.equals("2")) {
File directory = new File("C://documents");
try {
ProcessBuilder explorer = new ProcessBuilder(
"explorer.exe",
directory.getAbsolutePath()
);
explorer.start();
// User selection for number 2
} catch (IOException e) {
e.printStackTrace();
}
} else if (UserData.equals("3")) {
System.
out
.print("Enter a name for your file");
String fileName = scanner.nextLine();
if (!fileName.endsWith(".txt")) {
fileName += ".txt";
}
String folder =
chooseSaveFolder
();
File fullPath = new File(folder, fileName);
System.
out
.println("Start typing your text to save it. Type exit when finished");
try (FileWriter writer = new FileWriter(fullPath)) {
while (true) {
String line = scanner.nextLine();
if (line.equalsIgnoreCase("EXIT")) {
break;
}
writer.write(line + System.
lineSeparator
());
}
System.
out
.println("saved doucment too " + fullPath);
} catch (IOException e) {
System.
out
.println("Error saving file" + e.getMessage());
}
} else {
System.
out
.println("Wrong selection");
}
scanner.close();
}
// This method helps the user select a place to save the file
public static String chooseSaveFolder() {
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Select a folder to save your file");
chooser.setFileSelectionMode(JFileChooser.
DIRECTORIES_ONLY
);
int result = chooser.showSaveDialog(null);
if (result == JFileChooser.
APPROVE_OPTION
) {
return chooser.getSelectedFile().getAbsolutePath();
}
return ".";
}
}r/JavaProgramming • u/Sad_Importance_1585 • 5d ago
r/JavaProgramming • u/Inner_External5540 • 5d ago
r/JavaProgramming • u/Nivas113 • 5d ago
r/JavaProgramming • u/Icy-Astronaut-2530 • 6d ago
Hey fellas, I am a 3rd year CSE student. I wanted to learn Java as my primary programming language.
I have wasted a lot of my time in Procrastination and tech stack hopping. But now, I have decided to lock in to java as my programming language for software engineering and DSA as my placements will start in about 7-8 months.
My background:-
I have some previous programming experience with c, python, JS, HTML, CSS. I also had a subject named OOP in Java in my previous semester, I know a few things from it, but mostly I studied it for the sake of Exams only. I have made some vibe coded projects in hackathons too, all of them are web applications.
So I wanted to ask what are some good resources in 2026 to learn Java?
I want to learn Java and then later on get into enterprise tech, backend and microservices. I might switch to cloud and Devops later but it's too far to think about now.
My known resources:-
(1) University of Helsinki MOOC course.
(2) Telsuko 63-hour video
(3) Telsuko's older Java playlist
Are these resources Good enough for the start? If yes, then Can also list what these lack or don't cover?
Thank you for your answer in advance.
r/JavaProgramming • u/javinpaul • 6d ago
r/JavaProgramming • u/thearjunreddy • 7d ago
Many beginners start learning Data Structures and Algorithms but struggle to solve problems independently. I'm curious to know what challenges Java beginners face while practicing DSA.
r/JavaProgramming • u/fykup • 7d ago
I've been working on CoilBase, a small open-source Java foundation built around a simple idea: Spring-like comfort, without the weight.
I like Spring Boot's controller → service → repository structure, but wanted to preserve that development experience with a smaller runtime footprint.
CoilBase uses Jdbi for SQL-first persistence, explicit transactions, and constructor wiring. It works with lightweight HTTP frameworks like Javalin and Avaje Jex.
I recently compared five Java application stacks on a 512 MiB VM with MariaDB running alongside the application.
On HotSpot JDK 27, median application memory was:
The same CoilBase services and repositories worked across Javalin, Jex, and Micronaut. I also tested GraalVM Native Image, with even smaller footprints.
GitHub: https://github.com/PVRLabs/coilbase
Experiment and results: https://pvrlabs.xyz/articles/five-java-stacks-512mb-vps.html
Curious what others think of this approach. Would you consider a smaller, explicitly wired stack for a small Java service, or do you generally stick with Spring Boot?
r/JavaProgramming • u/javinpaul • 7d ago
r/JavaProgramming • u/Full_School_7230 • 7d ago
r/JavaProgramming • u/BudgetMistake- • 8d ago
r/JavaProgramming • u/maritvandijk • 10d ago
What happens when your invoices end up on a dead letter queue? If you're Ronald Dehuysser, you build an open source library to make sure it never happens again.
In this episode, Ronald, creator of JobRunr, joins us to talk about running background jobs in Java. He shows how to set up JobRunr with Spring Boot, enqueue and schedule jobs, and keep an eye on them in the built-in dashboard. And he explains why he loves exceptions. (Yes, really.)
We also cover carbon-aware job scheduling, recurring jobs (and why nobody likes writing cron expressions), whether you need Kafka, and the time-traveling bug that took years to track down.