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.

518 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
116 views

Android component animatable on its height

I'd like to have a code review for a component which is supposed to be animatable on its height. It's supposed to be a transitioning element. I find it quite laggy on my phone. ...
Astyan's user avatar
  • 79
6 votes
0 answers
787 views

Pseudo-parallel depth-first search

I'm writing a small program that generates a file containing an adjancency matrix, it then reads from that file, constructs a graph and does something like a parallel depth-first search (dfs) on it. ...
user3719857's user avatar
6 votes
0 answers
2k views

Implement two level caching using spring's cache abstraction Cache and CacheManager

Details about spring's caching framework are here. When I was reading this link, I thought the composite cache mentioned there was one that used levels of caching based on the order given to the ...
shrewquest's user avatar
5 votes
0 answers
147 views

Java OOP Hangman revision #4 includes UML

This is a continuation of this question. In the game the player chooses a topic and then gets a random word (or words) from that topic to guess. I've repartitioned the code into objects several times,...
scripta's user avatar
  • 501
5 votes
0 answers
1k views

Exception handling: using @JsonProperty value to make error message

If the validation in RestController fails, I need to handle MethodArgumentNotValidException and provide an errorMessage, that ...
Georgii Lvov's user avatar
5 votes
0 answers
60 views

Fragment of code with Android MVP that checks login credentials via REST API

I'm learning MVP for Android and am wondering if that piece of code that I wrote is correct in terms of this pattern or maybe is completely messed up. I'm wondering if there can be return type other ...
Abc Def's user avatar
  • 51
5 votes
0 answers
1k views

Mahjong hand completeness checking algorithm

As a summer project, I have been working on a small-scale, console-based version of Mahjong (the Rummy-like hand completion game, and not the solitaire version). While having prior knowledge of the ...
Joey Hunt's user avatar
5 votes
0 answers
2k views

Android audio recording using AudioRecord and ByteBuffer

I'm developing an audio recorder app for android using AudioRecord class to have a low level access to audio samples. ...
jalal's user avatar
  • 51
5 votes
0 answers
381 views

Optimizing Graph Algorithms for Floyd Warshall and Johnson Algorithm

I am trying to implement and compare Floyd Warshall and Johnson Algorithm(for Sparse Graphs). I have written the following code which produces correct output values for the all pair shortest paths. ...
kauray's user avatar
  • 151
5 votes
0 answers
229 views

A Java neural network

I have created a neural network in Java, it contains multiple classes. I have uploaded the documentation for the network here: Doxygen, and the full source can be found on Github. Let me start out by ...
tuskiomi's user avatar
  • 185
5 votes
0 answers
138 views

Writing service/network layer for mobile apps

I have an app that gets and posts blog posts to and from a server. Right now I have a network client object which is passed into a service object. The service object is created and called from an ...
Matt's user avatar
  • 183
5 votes
0 answers
137 views

User role Observable

I have a service with these methods: Observable<User> getUsers(); Observable<Role> getUserRoles(String userId); For each user, I want to get her ...
Héctor's user avatar
  • 151
5 votes
0 answers
14k views

Using the same RecyclerView.Adapter with a different ViewHolder

I would use the same RecyclerView.Adapter with two or more different fragments. Every fragment uses a different view items layout so I must use a different ...
Dave's user avatar
  • 111
4 votes
0 answers
37 views

FlashCard app using javax.swing

I made a simple flash card app. The general idea is from Head First Java, but it's one app instead of two (for both making cards and playing them) and the implementation is different. What do you ...
Sergey's user avatar
  • 511
4 votes
0 answers
79 views

Print columns of text without hard coding the width (attempt 5)

If you'd like to print this: ...
candied_orange's user avatar
4 votes
0 answers
3k views

Reactive JWT authentication using Spring webflux

Greeting to all senior devs here. I'm trying to create a project for my small business. There are not many tutorial on how to create Reactive JWT authentication with Spring webflux. So I'm a bit ...
Patrick's user avatar
  • 331
4 votes
0 answers
2k views

Android APP connect to FTP server in Java

I am attempting to build an Android APP with the ability to connect specified FTP server in Java. The connection operation has been performed in FTPconnection class ...
JimmyHu's user avatar
  • 4,406
4 votes
0 answers
147 views

Just a digital clock in Swing

I've written a little clock implementation in Java Swing. It now seems to work flawlessly after having terrible Swing specific timing problems. Please indicate if this is the way to draw the clock and ...
Maarten Bodewes's user avatar
4 votes
0 answers
221 views

Game of Life, thread per cell

In an effort to learn Java's support for concurrency I solved a self-imposed exercise to write a Game of Life simulator in Java, running a separate thread for each cell. Here is my code: ...
gaazkam's user avatar
  • 561
4 votes
0 answers
1k views

Parsing HTTP request for webserver implementation

I'm writing a web server from scratch on pure Java in learning purpose. As a part of request handling, I worked on a class to parse HTTP request, I expect from it to be able to do next things: ...
Campos Ilya's user avatar
4 votes
0 answers
78 views

Extracting cycles from directed graph with max degree 1 and then performing set cover on cycles

I'm trying to solve P1243E in an efficient manner. The problem in simple words is: Given \$k\$ boxes, \$i\$-th box with \$n_i\$ numbers. All numbers are distinct. We need to select one number from ...
RE60K's user avatar
  • 1,456
4 votes
0 answers
353 views

Java multithreading many readers one writer implementations

I have a shared data object with writer threads and reader threads. Number of threads can read from the shared data at the same time (in the code getmethod), and ...
user avatar
4 votes
0 answers
749 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 ...
Mark Vincze's user avatar
4 votes
0 answers
728 views

RGB to YCbCr conversion in Java

I found a Go language code to do RGB to YCbCr conversion from here! I ported it to Java: ...
lucky1928's user avatar
  • 173
4 votes
0 answers
1k 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 ...
Roland Illig's user avatar
  • 21.3k
4 votes
0 answers
138 views

Data processing program

I'm working on part of a service for data processing. The main idea of the service is to get the input data, process it and return the processed data to another service. Input and output data format ...
iRomul's user avatar
  • 41
4 votes
0 answers
692 views

Parallel solutions to N Queens Puzzle

I'm trying to increase the performance of my N Queens Puzzle solution. I'd find some threads on SO already but they don't appear to help me to increase performance. My best solution, however, is a ...
Noixes's user avatar
  • 141
4 votes
0 answers
506 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 ...
Juan Lopes's user avatar
4 votes
0 answers
267 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, ...
Lyubomyr Shaydariv's user avatar
4 votes
0 answers
98 views

Biometric data representation in Java

This code represents biometric data averaged over a 1min period, beginning at the given UTC time. Please review my code: ...
Vatsala Sonal's user avatar
4 votes
0 answers
218 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 ...
Equiphract's user avatar
4 votes
0 answers
432 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)...
Luca Sepe's user avatar
  • 141
4 votes
0 answers
4k views

Updating the UI without leaking the context after an Android AsyncTask finishes

In the past I always did AsyncTasks as private inner classes. The tutorials I found still recommend this (see here, here, here, and here). However, this has the potential to leak the context. Now ...
Suragch's user avatar
  • 405
4 votes
0 answers
9k views

Simple MVC CRUD with JDBC

I would like to review my simple piece of code. I am beginner (I learn java for 1 year) and I would like to find out whether I am on good way. I have created simple MVC CRUD java app "ProductManager"....
ReviewCody's user avatar
4 votes
0 answers
197 views

Instantiating an animal using fluent classes with inheritance

I've spent a couple of weeks implementing a simple text editor. The entire program uses only immutable objects and a functional, fluid programming style. After reading about ways to implement Fluent ...
LegendLength's user avatar
4 votes
0 answers
139 views

Dynamically creating login screen on Android devices

This has been an experience. I'm well above "hello world" java is not a language I use often when programming and I don't program too much. I find myself a lot on Google.... basically just about for ...
Nolan Robidoux's user avatar
4 votes
0 answers
252 views

SAP BPM API - Fetching ProcessInstance & TaskAbstract

I am using SAP BPM API's to fetch currently running process instance and the task belonging to the running process instance. I have return below method on an EJB Class which does the job, however it ...
Jeet's user avatar
  • 141
4 votes
0 answers
96 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 ...
Thomas Shemeld's user avatar
4 votes
0 answers
168 views

Simple Brainf_ck IDE in JavaFX 8

I have this simple IDE for playing with Brainf_ck. It has no file functionality; only the code, input and output fields are present, and the "compiler" is integrated. Here is how it looks like: My ...
coderodde's user avatar
  • 27.6k
4 votes
0 answers
2k views

JavaFX Scene Video Capture Utility

2 days ago as I was working on my game I decided I wanted to include some sort of a video showing sneak peaks of the themes and tutorials and such. I then decided to check how to record my scene or ...
Eudy Contreras's user avatar
4 votes
0 answers
2k views

Integer tree sort in Java

I have this algorithm for sorting integer arrays. Basically, it's a balanced tree sort which creates a tree node for each distinct integer, and in each tree node it maintains a counter counting how ...
coderodde's user avatar
  • 27.6k
4 votes
0 answers
148 views

Hash Based Data Structure in Java for Collision Calculation

I have started a project on my free time were I'm writing a 2D game engine in Java. One of the more challenging and interesting aspects of such a project is collision detection between sprites on the ...
mantono's user avatar
  • 161
4 votes
0 answers
5k views

Building a tree structure from pairs of parent-child to retrieve all ancestors of a leaf

I am trying to build a tree similar to this one : 1 / \ 2 3 /|\ 4 5 6 / 7 With that tree, I must be able to get all ancestors for each ...
l0r3nz4cc10's user avatar
4 votes
0 answers
313 views

Wavefront-Reader (.obj) in Java - Part 1

I want to implement a wavefront-reader in Java. Therefore I've created some classes to extract a Vector3f and Vector2f (I use ...
SleepyX667's user avatar
4 votes
0 answers
4k views

Hibernate and the Repository Pattern

I have already asked a question on stackoverflow on how to understand the Reporitory Pattern but I'm still having very big troubles in getting a good design implemented on my server. I'm desperately ...
Stefan Falk's user avatar
4 votes
0 answers
79 views

Advice on modelling with generics in Java

Use Case The third party library that I am working with implements its data model in this fashion. ...
Pete's user avatar
  • 2,284
4 votes
0 answers
100 views

Minimum amount of edges that needs to be traversed to visit all vertices... or something like that

So I have this problem, where I'm given m connections over n vertices. The vertices are labeled ...
Olavi Mustanoja's user avatar
4 votes
0 answers
627 views

Exception logger for servlets and JSPs

I hate using unnecessary catch blocks and I like to see my code look beautiful. In most of the cases in my project, which is a web application, I can't declare many ...
phoenix's user avatar
  • 277
4 votes
1 answer
125 views

Porting a web-based POS system to Android

I'm currently porting a web-based POS system to Android. The Android version uses NavigationDrawer to navigate between menus. What I need a code review on is my ...
TtT23's user avatar
  • 1,040
3 votes
1 answer
68 views

Java changing multiple panel

i want to create a gui that allow me to change through differents frame, i have a main frame where there are multiple button and when clicking on the button i want to open a new page (like a "...
Gabriele's user avatar

1
2 3 4 5
11