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 byte-code and run in a virtual machine (JVM) enabling a "write once, run anywhere" (WORA) methodology.

learn more… | top users | synonyms (2)

-1
votes
0answers
3 views

DICOM Image Orientation evaluation in Java

I have been trying to find this out since a long time, but due to lack of any experience in Java, I am totally lost. I want to do some operations in DICOM in Java. I have used ImageJ library to simply ...
1
vote
0answers
14 views

Play Market In App Billing

I want to add In App purchases to my application. In App in test mode works great, but there is no check on their authenticity. While googling some info about making server-side of In App I found out ...
1
vote
1answer
16 views

Replace an element of a List with a concrete id

I want to replace an object of a List with another one. To find the item to replace I need to check the field ID of the object to find what item is the same. Here is my code: ...
0
votes
0answers
13 views

android - custom ListAdapter with ViewHolder Pattern

I write this class for custom list adapter for my list view , I use view holder pattern to make list view move more smooth could any one advice me if I do something wrong , or something I can refine ...
0
votes
0answers
13 views

Storm - custom capacity aware stream grouping

This is the code to make a capacity aware stream grouping for Storm topologies. Please review this. The summary method has to be called every ten minutes once. future task - This method and fields ...
0
votes
0answers
21 views

Is my solution to this Java concurrency Bank exercise with multiple accounts correct?

I am doing an exercise in Java concurrency. The problem statement is as follows: Bank holds an array of Accounts. Client do (in a loop) the following operations: (1) work, then sleep for random ...
0
votes
0answers
11 views

Handling ManagedBeans and their data

I have the following Use-Case: On a Page(page1), a name of a Customer is entered and saved. The saved entity is displayed in a DataTable on the same page. The DataTable has the customers name in ...
3
votes
0answers
24 views

IntModulus long addition and subtraction

One of the remarks in this answer to my question concerning IntModulus says What's more problematic is that you don't have matching argument symmetry for add ...
3
votes
5answers
318 views

Insert k copies of each element in ArrayList

This method takes an ArrayList<String> s and int k , then creates k copies of each ...
3
votes
2answers
188 views

Set Game State from String

Before I used reflection to invoke a state based on the string. It looked like this. ...
5
votes
1answer
33 views

Caterpillar uneaten leaves

K caterpillars are eating their way through N leaves, each caterpillar falls from leaf to leaf in a unique sequence, all caterpillars start at a twig at position 0 and falls onto the leaves ...
-1
votes
1answer
38 views

MVC Architecture Project

I'm trying to focus on learning so I can get an entry level position and the best way for me to learn right now is to have someone review and provide areas of improvement. This project isn't entirely ...
11
votes
3answers
829 views

Fastest and minimal random access data structure in Java

I have written up a data structure in Java that supports the following features: get(i) set(i, e) ...
10
votes
4answers
2k views

Enigma Machine Simulation

This is an Enigma Machine Simulator written in Java: Enigma.java ...
2
votes
2answers
56 views

Parsing a text file of node data into Nodes and Edges

I'm a fairly new developer (well, engineer really, but currently working on a software project). In the Android project I'm working on, I read a node representation of a map into my app and interpret ...
0
votes
0answers
25 views

Sun's HttpServer Simple HTTP server design [on hold]

For an assignment I had to write a simple Http server (multithreaded) with the help of Sun's HttpServer. This server has to handle 4 resource (/login (GET), /cards (GET), /send (POST) , /list (POST)) ...
-1
votes
0answers
21 views

Production ready Socket server in Java [on hold]

There are many tutorials where explains about socket server/client sides, but all them are very trivial. Is there any tutorial for production ready code? I'm new in sockets. There is a client, that ...
7
votes
1answer
45 views

Media lending library

My assignment was to make a "Lending Library" that keeps track of items. We were advised to create two classes and a main method. What I am unsure of is if any of my code would be considered bad ...
6
votes
2answers
92 views

IntModulus reloaded

As my question Modular arithmetic was hard to review and terribly long, I've added a few comments to the easier part, namely IntModulus. The code uses Guava and ...
3
votes
1answer
101 views

A minimal HashTable implementation

For an assignment, I wrote a minimal HashTable implementation (it only supports additions; no deletions). To resolve collisions, it uses Linear Probing (required by the assignment). I'm looking for ...
4
votes
0answers
40 views

Blocking reads when writes are happening on two flows

I am trying to implement lock by which I want to avoid reads from happening whenever I am doing a write. My requirements are: Reads block until all three maps have been set for the first time. Now ...
3
votes
2answers
76 views

Passing data from one model to another

In my task I have to pass some data from one model to another, where each model contains lists: ...
11
votes
1answer
46 views

Translating the Rubberduck - Übersetzen der Gummiente - Part 1: Modelling

So I have committed to making a German translation for the guys over at Rubberduck, which is localized via .resx files. Now these files are basically XML-Files with a certain, rather simple document ...
4
votes
1answer
42 views

Multithreaded scoreboard for different levels

For an assignment I had to create a highly multi-threaded scoreboard for a multi level game. So every time a user adds a score if the level doesn't exist, it gets created ad-hoc. Important point: a ...
7
votes
3answers
389 views

Compute the day of the year

I am new to programming. I saw this Java code with a lot of if-else statements that is copied below. People say that such a code ...
4
votes
2answers
42 views

Binary Search Tree in Java

Please give me some feedback on how I could make it better or simpler. ...
10
votes
2answers
116 views

Random walk with equal probability

This method randomly increments or decrements (with equal probability) until either -3 or 3 are reached. I'd like to maintain printing the value of pos on each ...
2
votes
1answer
58 views

Checking for Internet connectivity on Android

I wrote this code to check an internet connection and was wondering if this is the best way to do this check. ...
3
votes
1answer
71 views

Converting a CSV file to a social network graph for Pajek

The code will ask for a directory and will then read the CSV file and then generate a file in that directory describing a social network for Pajek. Does anyone know a way to load this CSV file to a ...
7
votes
3answers
70 views

Writing a program to read a maximum of 99 elements in an iteration from a list

I want to read a list of elements and pass a maximum of 99 elements to a function for some logical operations. I have tried this with an array as an example and this code was successful in achieving ...
13
votes
4answers
332 views

Checking three values are consecutive

This question was recently asked: Determining if three numbers are consecutive It intrigued me, even though it was broken. I have the following implementation I thought would be interesting, and I am ...
2
votes
1answer
37 views

Find pairs in an integer array whose sum == 10

I'm practicing for technical interviews and I'm looking for ways to improve my answers/code. Please point out the flaws you see and how I can make this better. Task: Find pairs in an integer array ...
7
votes
6answers
579 views

Determining if three numbers are consecutive

This code will determine if three numbers are consecutive for any order they're supplied to the method (any permutation of [n, n+1, n+2] should be accepted). Is ...
3
votes
3answers
49 views

Java class for creating HeadPhone class and Test class

Here is the Assignment instructions: Create a Java class named HeadPhone to represent a headphone set. The class contains: Three constants named LOW, MEDIUM and HIGH with values of 1, 2 ...
1
vote
2answers
25 views

AsyncTask alternative with Runnable and CountdownLatch

What is wrong with this pattern which emulates AsyncTask functionality?: ...
2
votes
1answer
62 views

Finding the longest repeated substring in a string

After optimising my code it still seems pretty brute force and I am looking for ideas to fundamentally improve it. I have tried improving performance by: Avoiding creating substrings as much as ...
3
votes
1answer
39 views

Non-recursive approach to the Rod-Cutting

I've given the Rod-Cutting Problem a go with a non-recursive approach that use a cache instead, with a bottom up approach. For anyone who hasn't heard about the Rod-Cutting problem, it's defined as ...
2
votes
1answer
55 views
+50

Ball Entity for a Entity/Component/System Soccer Game - Revision 1

I made some refactorings in my classes. The original code is in this question. In that question I receive the suggestion to create a Factory for the class BallEntity. I myself forgot that BallEntity ...
7
votes
6answers
392 views

Conditionals for time specific data

This is a fun piece. I have this block of code here: ...
3
votes
1answer
25 views

Thread-safe irregular rate limiter

Google's Guava library has a great RateLimiter, but I also needed a way to limit on an irregular basis, such as if an API I'm using has been throttled. I basically built a wrapper around Guava's ...
2
votes
1answer
22 views

Tiny function to ensure a node of a BST has a valid relationship with its children

I need to write a method to ensure that all of the nodes of a BST (Binary Search Tree) are valid. For a node to be valid, 2 things must hold: The left child must be less than the current node's ...
2
votes
4answers
110 views

Print factors of number using fencepost loop

I was wondering if this code could be optimized in any way? For instance, could I use a for each loop here? Are there other ways I could write this which would make it easier for me, or the person ...
-4
votes
0answers
17 views

How can I convert this code the use breadth [on hold]

So I am trying to code a crawler but I am wondering how I can covert the code to breadth search instead of depth. I'm very new to java so please be nice. ...
1
vote
2answers
35 views

AES-encrypted key store

I am writing a program that needs to retain specific data but that should not be easily readable. I am in no way very skilled in crypto but I wrote this class that takes all of the data in and then ...
-2
votes
2answers
59 views

Comparing 2 ints without using comparative operators

I was looking for questions that might be asked in a technical interview and I found this one: Write a function that determines if two integers are equal without using any comparative operators. ...
2
votes
1answer
356 views

Extracting flights from result of an airline web service

I have the following code to extract results of an airline web service. I am wondering if there is any better approach to this. The code is supposed to ignore any flight that has more than 1 transit. ...
2
votes
3answers
84 views

Find number of whole weeks between months in the same year

I wrote a class to return the number of whole weeks between months in the same year. I need suggestions on my code. ...
4
votes
2answers
616 views

The stocks problem - find the biggest profit that can be made

The Stocks Problem: Given an array of n integers representing the price of a stock over the course of n days, determine the maximum profit you can make if you can buy and sell exactly 1 stock ...
-6
votes
1answer
41 views
3
votes
2answers
57 views

Ball Entity for a Entity/Component/System Soccer Game

Here is a code snippet of a class that I be interested to refactor. I was in doubt on how to proceed with the process of instantiation. The original ask was here. After think about it and heard some ...