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.

685 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
90 views

Java Android Sudoku solver

I made a simple and non recursive Android Java Sudoku solver implementing Algorithm X with links inspired from dancing links. The code is on Github (start with the Solver class and the ...
3
votes
0answers
72 views

Sequential master update

I'm creating a version of the classic sequential master file update in java. This is used when you sort two files by the same key for updating one file with the other. In this case, I'm pulling in all ...
3
votes
1answer
96 views

Implementation of generic Graph class and Dijkstras

I participate in competitive programming contests, and I found myself implementing and re-implementing graphs constantly. So I decided to create a reusable implementation of a Graph class, and ...
3
votes
2answers
57 views

I/O-TxtFile Line Distance Program

I am trying to write a lab/program that loops through a .txt input file. Reads an entire line of data as a string, then splits that string into an array delimited by a space. If there are 4 items in ...
3
votes
2answers
117 views

Displaying 21 spinners to select body parts

I just wanted to ask how can I make my code a bit shorter. As of now, I have way too much code in the class. The program should display about twenty one spinners. I know it's a lot, but in this layout,...
3
votes
1answer
166 views

Java console banking

So I wanted to write a basic console based banking app to practice my skills. It makes use of BigDecimal to ensure accuracy. Here is the MVP I plan to enhance it with all banking features soon. I ...
3
votes
1answer
128 views

ToDoApp - adding users, managing tasks, getting tasks

I've implemented a console ToDo application. I would like to hear some opinions about it, what should I change etc. About project: It is intended to manage everyday tasks. Application contains: ...
3
votes
0answers
58 views

Swing framework removing cyclic dependency between UI and Controller

I am creating a Java Swing Application which deals with Geographic and Stellar data and I need a solid framework on which I can build (now) and extend (in future) any functionality I wish to. I am ...
3
votes
0answers
81 views

Game of Life in Java using Swing

As a hobby project I implemented Game of Life in Java using Swing. I don't have much experience with Java using Swing and would like to get feedback on the code. One thing in particular that I would ...
3
votes
0answers
120 views

Java - propagating a threadlocal by wrapping a runnable

My aim is to use a thread pool together with a thread local. I cannot use InheritableThreadLocal because the thread data is different per user and there a couple of ...
3
votes
0answers
82 views

Enclosing JPA Boilerplate Code

This is an attempt to create interfaces holding the boilerplate code of basic JPA interactions. Code in question/review JPAInteraction.java ...
3
votes
1answer
2k views

Accessing Adapter data from ViewHolder

In my Android app, I need to disable a button in Layout if the api return status as 0. I get this status in the Adapter and based on it, I have disabled the button in ViewHolder which is inflating the ...
3
votes
0answers
127 views

ConcurrentLinkedQueue Object Pool implementation

I have implemented this simple unbounded ObjectPool based on a ConcurrentLinkedQueue of WeakReferences. I have a thread-unsafe object that is pretty expensive to create, and most of the time it will ...
3
votes
0answers
90 views

Minesweeper game loads very slowly from the Start Menu

I'm quite a beginner with Java and just this month started learning about GUI and JFrame so naturally the first thing I wanted to do was build a Minesweeper Game. ...
3
votes
1answer
250 views

Updating the icon of every JLabel in a JLabel ArrayList

I want to update every icon of a JLabel ArrayList, to its own individual icon based off of an outside ...
3
votes
0answers
43 views

Designing a system to apply multiple effects to one or multiple targets

I posted this on SO first, but was redirected here, since the code below already works: I'm currently trying to develop a small game as a hobby project, which contains an automated combat system ...
3
votes
0answers
164 views

Bloom filter algorithm usage in spring boot rest service

I have implemented spring boot rest service which has only one function - get status of invoices by unique ID. In the scope of this task I have implemented Bloom filter algorithm to avoid unnecessary ...
3
votes
2answers
191 views

Generating a string in a particular format by reading data from a map

I have a processToTaskIdHolder Map which contains processId as the key and taskId as the ...
3
votes
1answer
3k views

Android RecyclerView Adapter: Passing normal clicks and menu clicks over the same activity

I am unsure about my approach here. As you can see, I want to send normal clicks and 2 different menu item clicks back to the underlying activity over an interface. Now I wonder if it is bad practice ...
3
votes
0answers
90 views

Algorithm to find connected tiles (percolation)

I wrote a little program in JavaFX which displays a path of neighbouring open tiles going from top to bottom. It should simulate a percolation. The algorithm iterates through the whole grid (every ...
3
votes
0answers
120 views

Convert top-down subset sum to bottom-up

I have written the code for calculating subset-sum and also printing the first encountered non-empty subset from the left that sums up to the given sum. My code in Java is as follows: ...
3
votes
0answers
76 views

SPOJ Fast Matching challenge

I wrote a solution to the MATCHING challenge on SPOJ: FJ has N (1 ≤ N ≤ 50,000) cows and M (1 ≤ M ≤ 50,000) bulls. Given a list of P (1 ≤ P ≤ 150,000) potential matches between a cow and a bull, ...
3
votes
0answers
259 views

Custom ThreadPoolExecutor/ThreadFactory in order to submiting callables upon incoming ActiveMQ messages

I have a service that is subscribed to a specific channel of ActiveMQ. Every time a message arrives the service has to start a "job" (submit instances of Callables)...
3
votes
0answers
2k views

Matrix multiplication project using multithreading in java

Below is my code of matrix multiplication in Java. It has both implementation of matrix multiplication- one without multi-threading and another one using multi-threading. For multi-threading ...
3
votes
0answers
822 views

Putting thread in sleep while waiting for BroadcastReceiver

I'm a little puzzled about a procedure inside my Android app. It's actually working but it looks like bad practice and probably it lowers performances. Short explanation: I'm running a separate ...
3
votes
0answers
222 views

A TDD Exercise on Snakes and Ladders

I finished the Snakes and Ladders kata in the Agile Katas and I would like to know if there's a way to improve my code (specifically the part where the turn order is determined). Game ...
3
votes
1answer
2k views

Custom ResponseModel for Spring Controller - ResponseEntity<?>

I created a custom responseModel to have a standard json responseModel for some of my different RestController. Superclass TransactionResponseModel: ...
3
votes
0answers
669 views

A Java library for simulating logic circuits

I have this Java library for building logic circuits and running binary data through them: AbstractCircuitComponent.java ...
3
votes
1answer
455 views

Creating an image in Excel using the colors from an input image

I'm having some performance issues in this code and need some suggestions on how to improve it. I'm not interested in "general code style" improvements unless they have performance implications. The ...
3
votes
0answers
820 views

RxJava2 custom Observable

I'm trying to understand how to bridge receiver-based events to the Reactive world. I asked a question on SO and was pointed to a different approach. The author of that answer (David Karnok) is ...
3
votes
0answers
40 views

oEmbed provider servlet to handle four media types

I would like to add oEmbed tags to my site (I'm the oEmbed api provider). My api should respond the results based on the file type. oEmbed Types has Photo Video Link Rich My response to photo ...
3
votes
0answers
1k views

Structure of a serial port reading program

I am writing a serial port communication app. And I thought I could get some feedback about the general structure of the program. If I am doing MVC correct, etc. Since this is a "large" program I ...
3
votes
0answers
66 views

Initialising numerical properties from a text-based properties file

This is a Spring Framework-based datasource instantiator which reads its properties from the Spring Framework context, i.e. the values are initially all String from ...
3
votes
1answer
51 views

Storing variables to a map by splitting a text file

I'm currently making a social media app that contains profile details such as interests in a text file. The following code works by using markers in the text file to upload these details to map data ...
3
votes
0answers
175 views

Drawing in libgdx

I have made a Java clone of the popular 2048 game. It works, but I drew the UI in the correct way. Images so you know what we're discussing: I'm basically not sure how to do this, whether I should ...
3
votes
0answers
42 views

Regularly watch recent posts of a blog for specific words with HTML scraping

Task I want to watch the "Recent Posts" section of a blog for changes/new posts but only for specific posts containing a pre-defined word. Afterwards a list should be outputted in the console with ...
3
votes
0answers
44 views

Loading image/texture sprites on GameScreen in LibGDX

I'm new to this framework, LibGdx. I need advice/suggestion for my game. Is it okay if I load my images in a single class? I'm a beginner and started learning LibGdx. I already coded my game screen ...
3
votes
0answers
2k views

Repository pattern with Specification queries

I'm working on an Android (Java) project which utilizes different analytic metrics (sum of x group by date, sum of x group by id, etc) and I am projecting the data sets into different charts using ...
3
votes
0answers
436 views

Excluding resources from maven dependencies while exporting project to jar

I have two local maven projects A, and B. B is dependent on ...
3
votes
0answers
28 views

URLEncoder implementation Round 2

Half an year ago I posted an implementation of a URL encoder for review. I didn't have any time to work on it until recently, but now looking at my old code with new eyes I saw how unreadable the code ...
3
votes
0answers
240 views

Optimal Implementation Choice for Producer-Consumer in Java

I am looking for an optimal producer-consumer implementation in Java with the following aspects: Producer reads from server1 socket, and writes to a shared buffer, as well as another server 2 socket: ...
3
votes
0answers
592 views

Convert Unicode text to font glyphs for display on Android devices

Prior to Android 6.0, Mongolian text is not supported on Android devices. And as far as I know, OpenType smart font rendering is still not supported. Therefore, in all my Mongolian apps I use a ...
3
votes
0answers
54 views

Partition numbers as polynomial, each number in a thread

I'm beginner at multithreading programming and I wanna write a piece of my code using it. I'm trying to split different numbers into multiple parts and store them as a polynomial. I wanna do this ...
3
votes
0answers
202 views

Generic Factory using Function library

Here's my implementation of Generic Factory using Function library. It was created using Function library because I understand that the newInstance method is ...
3
votes
0answers
379 views

Java Pong Game Using Swing

I've written a Pong game in Java using the Swing library, and while the code works, the ball seems to lag across the screen. Perhaps my code is inefficient. I've included only the Board class because ...
3
votes
0answers
199 views

Hex Color Analyzer in javafx

Here is a simple hex color fetcher and analyzer in javafx that i wrote to understand multi-threading in javafx. Questions: Is my regex ok ? or if it can be improve? I am not much familiar with ...
3
votes
0answers
88 views

Simplified Google Maps program

I've been trying to write a simplified Google Maps program. My programming experience is limited. I have come up with a solution but I'm looking to make it more user friendly by splitting it up into ...
3
votes
0answers
4k views

A BaseActivity to render toolbar and navigation drawer

I'm new to Android programming and this is my first project so I'm not sure if this is the correct method of rendering the toolbar or the navigation of the drawer on the screen: So I have a ...
3
votes
0answers
94 views

JFreeChart generic plotting tool

I have created a bit of code that plots data for a project (XY Line Chart). It works. But it isn't what I'd consider good. I am looking to improve it in two ways: Make it more generic, so that I can ...
3
votes
0answers
56 views

Interpreter in Java for S.I.L.O.S., a custom language

I designed and implemented a custom language. After @LeakyNun refactored it to improve speed, it looks like this. I personally like it right now, but is there any more hyperoptimizations for both ...