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.

678 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
57 views

Rest API in a trimmed model

I practiced my Java knowledge in the last couple of days. For that, I want to create a Rest API in a trimmed scale, because there a lot of aspects which must be considered in such an API (Login, ...
3
votes
0answers
227 views

Java implementation of Spider Solitaire

I recently cloned a classical Spider Solitaire game from Microsoft Windows XP. I implemented almost all features of the game. Please tell me anything I can do in order to improve my coding style. ...
3
votes
0answers
58 views

Using functional interface arguments in methods of services injected via Spring

Here is the working code for my Spring service: ...
3
votes
0answers
108 views

Java code to convert BigDecimal to/from .NET decimal

Background In many languages we have built-in data types for representing decimal floating point numbers. In .NET that's decimal, and in Java we have ...
3
votes
0answers
242 views

Android+Firebase testing using Mockito

I have an interactor/usecase class in my application. My application follows MVVM architecture with interactor/usecases responsible for logic (e.g. get data from api-service, store in local-database ...
3
votes
0answers
89 views

Java game: select numbered tiles to form a goal sum

This is a homework project (Soft. Eng.) which I have completed. My teacher gave me a 91, but I am unhappy with this grade because my code is quite messy. (Please excuse incomplete Javadoc, the code is ...
3
votes
0answers
38 views

Load all data from cursor

I have a Db table: 'aid' INTEGER, 'tid' INTEGER, Which represents connection between activity and task, so multiple tasks could be connected to one activity ...
3
votes
0answers
92 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
39 views

Add up values from one field for multiple months

I have data as follows: Payment Date 11/01/18 01/01/2019 11/01/09 11/01/20 Total Amount 4536.87 4654.98 4698.63 4687.69 I need to add up all of the ...
3
votes
0answers
73 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
167 views

Stopwatch utility class in Java

Looking for input on my code for a Stopwatch utility written in Java. ...
3
votes
0answers
77 views

Solutions for counting trapped water on islands

There are some exercises about islands and water. I have seen other solutions in Java, but they are developed in procedural style in one-two methods. I tried to develop an object-oriented solution ...
3
votes
1answer
130 views

Calculate arithmetic expression represented by a string, in Java

I saw that interview question online and gave it a try: Implement a function that gets a string which represents an arithmethic expression: contains only numbers or the the operators: '+', '-', '*', '/...
3
votes
2answers
61 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
0answers
132 views

Object Oriented design for a live auction taking in bidders

My goal is to design an Auction that will take in data like this: ...
3
votes
2answers
132 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
142 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
61 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
83 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
147 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
87 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
3k 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
161 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
95 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
0answers
48 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
157 views

Implementing a tabular pretty-print using Java 8 Stream API

About six years ago I implemented a simple tabular pretty-print Java class that mostly simulated MySQL CLI query result tables. I don't really like it because it was implemented in a, I believe, ...
3
votes
0answers
201 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
0answers
127 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
81 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
315 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
928 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
275 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
0answers
805 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
0answers
50 views

Number of ways to complete a plan

I worked on a dynamic programming problem. Here is its link. I have to find the number of ways respecting the constraint that user doesn't go to the Gym for two consecutive days. ...
3
votes
0answers
870 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
67 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
0answers
186 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
43 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
45 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
481 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
252 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
676 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
211 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
404 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 ...