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.

666 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
392 views

Many-readers-one-writer with semaphores and multithreading

I've been looking for a solution to the may readers one writer in Java. I was intrigued by this question posted here and I read the Wikipedia entry about it. So far, I've reached a fine solution, or ...
2
votes
0answers
247 views

Let Them Eat Lists, Eventually (Asynchronous Generic List Consumption with Spring and CompletableFuture)

I want to reduce some repeated code in my Java 1.8/Spring Boot application, and to that end I tried to make a reuseable asynchronous utility module. In essence its an async List.forEach that takes a ...
2
votes
0answers
67 views

Firebase login/registration process for a dating app

I am developing another bigger project, I want to try a simple DatingApp and currently I try to develop a Login and Registration Form. There is no special register / login button, the code will later ...
2
votes
0answers
32 views

Sharing File (Content) without saving it before

I have a listview of PrivateFile objects which contain the fileId (int), fileName (String) ...
2
votes
0answers
109 views

Color picker using WritableImage in JavaFX

I am making my own JavaFX color picker just for learning more about JavaFX. I am rendering a color wheel in JavaFX using WritableImage and I have a ...
2
votes
0answers
450 views

Mouse wheel scrolling for nested scrollable Swing components

By default, mouse wheel scrolling in Java Swing behaves differently than in web browsers. In Swing, when you have an inner scrollable component and an outer scrollable component, the mouse wheel ...
2
votes
0answers
83 views

My first Java app: a calculator in Swing

I have created my first Java app. I am very familiar with C++ and thus without reading any books (just introduction, googling and IntelliJ auto-completion) I directly jumped into Java. So I made a ...
2
votes
1answer
1k views

Simple Java OOP calculator with GUI

I'm learning Java and I've tried to write my own calculator with GUi based on this post. Here is the repo: https://github.com/MurDaD/java-calculator Could someone check my code and tell me how to ...
2
votes
1answer
73 views

Enforce printing sequence using wait() and notify()

This is a follow-up answer "implementation" to a question I posted on SO. For the sake of convenience, I will repeat my intent: I want one thread (called sub-thread) to print 10 times under outer-loop ...
2
votes
0answers
35 views

Comparing performance of multi- and single - thread search of a maximum number

I have a class that compares the performance of two methods (multi- and single- thread) that searches for maximum number in the string of numbers. I want to improve the performance of a multithreaded ...
2
votes
0answers
181 views

Longest Palindromic Substring challenge

My code is a mix-up between dynamic programming with the HashMap and brute force with the way I reach out the results and substring. I don't know how to optimize my ...
2
votes
0answers
76 views

Yoga Android app

I have created a yoga app on Android Studio. Can someone review the code to see if I have used the best practices of programming? MainActivity: ...
2
votes
0answers
59 views

Program to generate Armstrong like numbers (java)

Armstrong like numbers are those which are equal to the sum of the cubes of their 1/3rd parts. For example: \$165033 = 16^3 + 50^3 + 33^3\$ \$166500333 = 166^3 + 500^3 + 333^3\$ Here is ...
2
votes
0answers
68 views

DFS logic to traverse a graph

I tried to literally convert recursive algorithm taught here to iterative, by simulating the recursive stack exactly as much as possible. I have tested my code and it passed all test cases. Please ...
2
votes
0answers
735 views

Create HttpClient using PoolingHttpClientConnectionManager

I have a java service class which will call a REST service and get response back. It is working fine in developer environment where less requests are made, but I still wanted to get a review. My ...
2
votes
0answers
78 views

Classical Single Pivot QuickSort implementation in Java using Generics

I have coded the following quick sort implementation. There are few things that still makes this code ugly and redundant. 1. Handling Arrays of Primitives I have to write a separate implementation of ...
2
votes
0answers
35 views

Wait until thread is stopped from within thread

This is an abbreviated version of a serial receiver that can be started and stopped like a resource. The idea is that a thread will listen to an InputStream and ...
2
votes
0answers
93 views

Java GUI application for selecting players

I have automated a small task. My application is a windows based application. I was using Java language and worked with Winium tool. I have to select players from the GUI and there is a scroll up and ...
2
votes
0answers
104 views

Tic Tac Toe game becomes more inefficient as time goes on

I designed a tic tac toe using 4 classes. The game class being the main class, the board class being the board, the player class being the decision making, and the AI class keeping the previous game ...
2
votes
0answers
35 views

Using a Queue of Supplier<Boolean> to control flow

I have a sequence of methods which should only be called if the previous returned successfully. If a method is successful it returns true, otherwise it returns false. Please tell me what you think of ...
2
votes
0answers
35 views

Security exceptions

I'm trying to configure security exceptions to all JavaScript/CSS of my pages. I need to login to access the JSP files, except the login page, but all pages needs ...
2
votes
0answers
55 views

Implementation of MVC pattern for single and multiple objects

I've implemented a student administration with MVC pattern (Tutorial: Link). I've decided to divid the students in "SingleStudentModel" and "MultipleStudentModel", but I'm not sure if that make sense ...
2
votes
0answers
159 views

Throttle submissions to ExecutorService

To prevent an XY problem, I'll first explain the problem I am trying to solve: Problem I am trying to solve I want to send the contents of a MongoDB collection with a size of around 3 million ...
2
votes
0answers
37 views

XML Input Parser To Load Test Data into Dev Database

I wrote an XML input transformer to ingest data from test directory and essentially store anything into a DB table. I attempted to make this as generic as possible. I'm new to Java and also realize ...
2
votes
0answers
47 views

Shortest path via intermediaries

Created a shortest path finder that must pass via sets of intermediary edges (either one in each set counts as a pass) in order. Primarily I would like to know if there are logical fallacies in the ...
2
votes
0answers
202 views

Unit/Integration Tests for Maven plugin that creates Skipper packages

I am writing an extension to a maven mojo (spring-cloud-skipper-maven-plugin) and I am now writing tests that interact with a skipper server. However, getting the ...
2
votes
0answers
263 views

Show mobile SoundCloud player in WebView

Demo for a SoundCloud player in WebView for specific song or artist stream as a workaround because SoundCloud is not accepting API key request anymore. SoundCloudWebView: ...
2
votes
0answers
552 views

Three sum using binary search

Given an array and a value, find all the triplets in the array whose sum is equal to the given value. For example, if the given array is {12, 3, 4, 1, 6, 9} and the ...
2
votes
0answers
49 views

Write one string to a socket within 10 seconds or another string if the time is out

I have implemented a method which will send one data to the server if it (Raspberry Pi Pin Input HIGH, in this case) occurs within 10 seconds. If this doesn't happen within 10 seconds then I should ...
2
votes
0answers
171 views

Encapsulation of putpixel is terribly slow in JavaFx

I am trying to write a simple rendering engine in JavaFx and I manage encapsulate putpixel in the way that I pass x,y coordinates and color and it draws pixel of that color to the screen. I also wrote ...
2
votes
0answers
73 views

Customer lookup system

I am new to Java programming and this is my first assignment. I have worked tirelessly to make sure everything works. What I am looking for is to see if there is any better way I can optimize or ...
2
votes
0answers
87 views

Computing most-cost effective loans in financial graphs using Java

Problem statement We are given a directed graph \$G = (V, A)\$, where \$V\$ is the set of actors and \$A \subseteq V^2\$ is the set of directed arcs. Existence of an arc \$(u, v) \in A\$ is ...
2
votes
0answers
64 views

Initiate, propagate, validate, send, and marshal a message in Spring

Purpose of code The goal of this code is to: Initiate a message propagation to other systems Validate that the given message adheres to its XSD schema, and then marshall it Send it on a Camel route ...
2
votes
0answers
559 views

Really basic ring/circular buffer in Java

I needed a simple way to run tests on the last n bytes of data received from a socket, and a ring buffer seemed to be the most efficient way to handle it. This is a very basic buffer that stores ...
2
votes
0answers
40 views

Optimizations for Knapsack with 3 dimensions

Problem Statement: I am given a set of prices for \$n\$ items I have to find out what is the maximum value I can get with \$M\$ money by selecting exactly \$C\$ items without exceeding the amount of ...
2
votes
0answers
118 views

Find a (nearly) optimal route among several locations that can be found by Google Maps

The README should give you all of the information you need for a comprehensive review, and if it doesn't then please say so. If you would like to contribute a review but do not have time or desire to ...
2
votes
0answers
2k views

Implementation of reactive file write from InputStream

I want to implement reactive write to file. In low level, it uses NIO and Futures. After reading this section I created this code but maybe there's more clean or less code solution. Thanks. ...
2
votes
0answers
49 views

Filter results on response

I call remote server to get my result. Result might contain artist,track and album depends on API method but there will be only one response (artist or track or album) at a time. It mean the other two ...
2
votes
0answers
105 views

Affine transformations in 2D space

During the past few days, I played around a bit with an SVG file, trying to minimize its size. One thing I stumbled upon was this transformation: ...
2
votes
0answers
277 views

Calling PL/SQL functions using JDBC in a Spring clone

I started to modify some old code and ended up creating a sort of spring jdbc framework. I know just the most popular design pattern, so I was wondering if my design was good. For example, to call ...
2
votes
0answers
1k views

Java Socket Proxy

I've been messing around with protocol handlers in Java, going so far as to write my own using a custom URLStreamHandler and ...
2
votes
0answers
394 views

Wrapper for sql.Connection

I wrote wrapper for Connection. It uses my Connection pool implementation. When the wrapper closes, the connection goes back to pool. ...
2
votes
0answers
528 views

Flattening a map into a list of records

In my everyday work I'm trying to move away from traditional iterating over collections to a more Java 8 streams-like behavior. I'm currently working on a project where I have a collection defined as: ...
2
votes
0answers
68 views

Scala code that loops through Java annotations decorating Scala classes

I have code written in Scala that reads annotations decorating other Scala classes. These annotations are written in Java. The sticking point is that annotations don't allow advanced data structures, ...
2
votes
0answers
1k views

Polling implemented using reactive framework (project reactor)

I have a use case where I need to poll a certain service till all data has arrived. The service accepts a list of ids and responds with data corresponding to these ids. Data is asynchronously made ...
2
votes
0answers
752 views

Handling single items using MVVM and Android Architecture Library

What I have done so far Since I would like to rebuild a project using mvvm-pattern with the following requirements to use dagger 2 for di, RXJava for reactive, retrofit for webservices, greendao and ...
2
votes
0answers
264 views

Generic Builder in Java needs annotation support

I was thinking about how to minimize the code needed to implement a builder. There is some code that any builder needs to have: Temporary storage of property values Validation of type Null check ...
2
votes
0answers
50 views

Regex to find wildcard imports in Java

Could I get a review on the following regex: ^import[\s\S&&[^\*\n]]*?([\*]{1}\;\s*$) All the details: Years ago a colleague shared a useful little regex ...
2
votes
0answers
277 views

Threadsafe static initialization of ExecutorService

I am trying to create a threadsafe singleton class based on Initialization-on-demand holder idiom . Here is my code ...
2
votes
0answers
94 views

Improved Atkin-Bernstein sieve for generating primes

This is a class from my personal code library, and from a package which deals with integer sequences. It implements an interface ...

1 2 3
4
5
14