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.

699 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
0answers
80 views

Generate unique random strings considering collisions

I'm coding a random strings generator. It's working, but I'm not sure if this is efficient. ...
6
votes
0answers
270 views

Implementation of Gitlab CI + Docker + Spring Boot

i would really appreciate if anyone could invest a bit of time to review what i did. Basically this is first time i do this, and that is reason why i need another set of eyes. I have Spring Boot ...
6
votes
0answers
104 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. ...
6
votes
0answers
659 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. ...
5
votes
0answers
93 views

Python version of Clean Code book example

I started reading Robert Martin's Clean Code. I'm trying to "translate" all his examples into Python, so I can understand them better since my domain on Python is greater than on Java. ...
5
votes
0answers
214 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 ...
5
votes
0answers
1k 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. ...
5
votes
0answers
204 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 ...
5
votes
0answers
126 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 ...
5
votes
0answers
120 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 ...
5
votes
0answers
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 ...
5
votes
0answers
13k 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 ...
4
votes
0answers
26 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 ...
4
votes
1answer
48 views

Displaying some multiples

Displaying Some Multiples Write a program to calculate the multiples of a given number. Have the user enter a number, and then use a for loop to display all the multiples of that number from 1 to 12. ...
4
votes
0answers
70 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: ...
4
votes
1answer
58 views

Recursively merge n-level maps of values and lists

I was looking for a solution for a way to easily merge maps of serialized Yaml and came up with this. Reference to a similar question (not asked by me): https://stackoverflow.com/questions/25773567/...
4
votes
0answers
31 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: ...
4
votes
0answers
69 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 ...
4
votes
0answers
132 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 ...
4
votes
0answers
420 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: ...
4
votes
0answers
128 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 ...
4
votes
1answer
197 views

Initializing an Android activity by reading a CSV file with image IDs, names, and descriptions

I am using Java to create an Android app. I have the main activity read a CSV file, create objects, and then save them into a singleton class so the rest of the activities in the app can access them ...
4
votes
0answers
379 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 ...
4
votes
0answers
324 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. ...
4
votes
0answers
193 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, ...
4
votes
0answers
91 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: ...
4
votes
0answers
128 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 ...
4
votes
0answers
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 ...
4
votes
0answers
7k 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"....
4
votes
0answers
134 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 ...
4
votes
0answers
106 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 ...
4
votes
0answers
197 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 ...
4
votes
0answers
91 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 ...
4
votes
0answers
159 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 ...
4
votes
0answers
1k 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 ...
4
votes
0answers
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 ...
4
votes
0answers
118 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 ...
4
votes
0answers
4k 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 ...
4
votes
0answers
245 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 ...
4
votes
0answers
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 ...
4
votes
0answers
76 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. ...
4
votes
0answers
91 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 ...
4
votes
0answers
601 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 ...
4
votes
1answer
109 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 ...
4
votes
2answers
901 views

Custom Thread Pool - Reusing non-busy threads

This is an exercise in thread pooling in which I attempt (hopefully in a successful manner) to reuse existing threads (much like Java's own ...
3
votes
0answers
86 views

Migrate customer and transaction data from CSV to MongoDB

I wrote a Java Spring Boot application with MongoDB that on every application start loads customer, account type and transaction details from CSV files to MongoDB. It has one end point that returns ...
3
votes
0answers
83 views

Putting as many ships on a square board as possible

Github repository Origanally I wrote a program that let you play battleship against the computer. Pretty easy: create a number of ships generate random cells for all the ships let the user try to ...
3
votes
0answers
30 views

Optimizing the topological sorting

I have implemented the topological sort. Is there any suggestion for optimizing the solution? Thanks. ...
3
votes
0answers
56 views

Hashing and sliding window for string

I have implemented a solution for finding all anagrams. Are there any other suggestions for improving the solution? ...
3
votes
0answers
42 views

N-elements byte array to integer conversion (little/big endian and signed/unsigned)

I'm trying to come up with a function to convert byte arrays to their integer representation, using both endianness, and with a signed/unsigned option. ...

1
2 3 4 5
14