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.

684 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
0answers
88 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
549 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
70 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
108 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 ...
5
votes
0answers
896 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
177 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
2answers
2k views

Loop for inserting a node into a binary search tree

I am trying to implement binary search tree. One method which I am trying to implement in the most efficient and stylish way is node insertion. I am under the impression that while (true) is a bad ...
5
votes
0answers
3k views

Java AES-256 GCM file encryption

I wrote my first file encryption program, that encrypts a file with AES-256 GCM and stores IV and salt prepended to the file content, so it's likely that I did something worse than possible. I ...
5
votes
1answer
676 views

Strongly connected component finding based on the guava graph library with Kosaraju

I have been writing a small compiler generator for which I need to solve the strongly connected component problem. As the Guava library contains, to my knowledge, no implementation for that problem, I ...
5
votes
0answers
119 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
3answers
500 views

Organizational Tool GUI with Java Swing (and GridBagLayout)

My first 'large' project is to create an organizational tool. Right now, it's pretty basic, but nevertheless functional in terms of the intent of the current release (v0.3.0). My main question is: '...
5
votes
0answers
109 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
14k views

Spring MVC dynamically adding form elements

I made a simple form with an option of adding one text field dynamically on mouse click. And I will be grateful for suggestions on how I may improve the code. ...
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
12k 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
1answer
110 views

Java program to encrypt/decrypt text

I am working on adding a GUI to the project that I was making in some course. I am curious if the layout looks good, if there variables and methods are shared properly between particular classes, if ...
4
votes
0answers
56 views

Sandbox file system for Java

I've recently started work on a hobby project that's basically a sandbox file system written in Java, slightly inspired by PhysicsFS. The point of the project is to separate what files a user can read/...
4
votes
0answers
88 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
119 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
160 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
249 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
259 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
90 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
1answer
4k 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 ...
4
votes
0answers
98 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
3k 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
1answer
470 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 ...
4
votes
0answers
6k 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
115 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
105 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
158 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
156 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
108 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
3k 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
197 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
74 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
88 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
579 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 ...
3
votes
1answer
81 views

Knuth-Morris-Pratt algorithm in Java Finding substrings in a matrix

Problem Given two matrices: a pattern p and a text t. Write a program that counts the number of occurrences of ...
3
votes
0answers
37 views

Concurrency control between a non-blocking and a blocking methods

In this program, there is a list of Holders that is managed by a singleton class. Each of the Holders keeps a copy of the ...
3
votes
0answers
38 views

HTTP Delete,Put,Get,Post REQUEST java-ee RESTful services JPA CDI EJB

I am creating introduction app to java ee and APIs of java ee and i want know if my code is ok (like its working but if it could be done better) and what should i avoid in future ...
3
votes
1answer
85 views

Ensure difference between sets

An endpoint that my application interacts with allows you to specify which fields are returned in the JSON result. My application will then map the JSON to a POJO using Jackson. Quite often I add more ...
3
votes
0answers
55 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
143 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
54 views

Using functional interface arguments in methods of services injected via Spring

Here is the working code for my Spring service: ...
3
votes
0answers
87 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 ...