Questions tagged [java]
Java (not to be confused with JavaScript) is a class-based, object-oriented, strongly typed, reflective language and run-time environment (JRE). Java programs are compiled to bytecode and run in a virtual machine (JVM) enabling a "write once, run anywhere" (WORA) methodology.
10,839 questions
4
votes
4
answers
391
views
Finding Special Parts in a Word
Task description:
Imagine you have a long word made up of small letters like "a", "b", "c", ancd so on. Let’s call this word a puzzle word.
We want to look at all the ...
4
votes
1
answer
70
views
Efficient way to win points in chocolate bowl game
I'm working on an optimization problem involving a turn-based chocolate-sharing game, and I need help optimizing my current brute-force solution.
Problem Description:
You and your friend take turns ...
6
votes
1
answer
339
views
Tic Tac Toe - Stage 2: console PvP + PvE + "EvE"
A while back I had opened this topic: Tic Tac Toe - Stage 1: console PvP
I had to put that mini-project on hold due to exams, but I've started working on it again a couple of days ago. Now it's ...
1
vote
0
answers
50
views
repllib.java - a tiny Java library for implementing simple REPL (Read, Evaluate, Print, Loop) programs
I have this GitHub repository - repllib.java. Basically, it's a simple class library for coding REPL functionality with simple format. A typical session may look like this:
...
-2
votes
0
answers
44
views
Priority Queue with Templates in Java with NetBeans [closed]
Does this code works like a priorityQueque? if not, wichc changes should i do to make it work like one, what should i do to improve it, using templates(any type), I have researched a lot about ...
0
votes
0
answers
57
views
Wait for results/failure of an unreliable async operation
Abstract Problem
The basic problem is that of producer/consumer. Wait for an async Producer to [produce an item] or [fail], together with a timeout on the consumer side.
Using Java's ...
4
votes
1
answer
181
views
Implementing Dependency Injection into a JavaFX CRUD Application
As a learning exercise and potential portfolio piece, I decided to create a Java/JavaFX application with MySQL integration.
I used dependency injection because it seemed like the cleanest way to pass ...
9
votes
3
answers
4k
views
Fixed-size array-based implementation of a queue
For my computer science class, I've implemented a Java version of a queue and would like to know if there's anything wrong with it. After my tests, it seems to work fine, but maybe somebody can point ...
5
votes
4
answers
477
views
Count number of substrings in less time
Given an input string contains letters from 'a' to 'g'
Count how many substrings are there in the input string such that
frequency of any character inside the substring is not more than the
number of ...
4
votes
2
answers
520
views
Simple Java program to aggregate lines of a text file
I have just written a small application to aggregate the lines of a text file, for example to group the lines according to the frequency of IP addresses in a log file.
Would the code be sufficiently ...
4
votes
2
answers
110
views
Custom RowSorter that sorts a Swing table containing data with unit suffixes
I would like to hear what you say about my custom RowSorter implementation.
The following comparators should be used for the table columns: String, Double and Integer.
The table data has postfixes and ...
7
votes
3
answers
2k
views
Java JDBC: MySQL database-wrapper
I'm currently enrolled in a further education with the topic database administration.
Among other chapters it contains how databases can be accessed from application-software.
Because it lacks ...
-1
votes
5
answers
2k
views
How to rewrite if.. else statements in a more elegant way [closed]
I created this short method:
...
6
votes
7
answers
1k
views
Filter non-even elements from an array
I have a method that returns an int[]. The array is made by filtering out only the even values of the array passed into the method.
It works, but it's really ugly ...
3
votes
3
answers
604
views
Collection-like classes in Java - taking advantage of varargs
I quite often need to implement collection-like classes and - to make using them more comfortable - would like to take advantage of a constructor with variable arguments.
The following implementation ...