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)

2
votes
1answer
27 views

Domain Model Service

I am writing some code that will serve a website and I have some questions about my "architecture". Domain - I have a database and and at the lowest level I have the **Domain* *package that contains ...
3
votes
4answers
40 views

Console Card Game - Contract Bridge

My project has three classes: Card, Deck, and BridgeConsole. The ...
3
votes
1answer
30 views

Create Java object from from page content or plain text

My job is to make a specified java objects from web page that contains following text: Companies: ...
3
votes
2answers
22 views

REST service to list new, continuing, and terminated subscribers during some period

I have a use case which says: Your REST service will consume a JSON object that contains a list of emails for subscribers at the start of the subscription period, and a list of subscribers at ...
4
votes
4answers
123 views

Permutation of n lists

I have code which gives permutations for 10 lists. The code works fine for small number of lists with small number of values. Result : It should return all possible permutations. I have to store the ...
2
votes
2answers
38 views

Effecient Use Sieve of Eratosthenes algorithm

Given this as a the Problem Statement Given two numbers, find the sum of prime numbers between them, both inclusive. Input: The first line contains the number of test cases T. Each ...
3
votes
2answers
31 views

Getting a set of subscribers from a subscriberMap

In my Java event bus project, I have a private generic method that retrieves a Set<Subscriber<E>> from a private ...
0
votes
1answer
21 views

Assigning instance field inside method

Look at the method setupCamera. I use it to reduce the size of the create method. As you can see, inside this method I instantiate camera and viewport, that are fields. Is there any problem to do ...
0
votes
0answers
14 views

Android MVP using Headless Fragment as Presenter

I've been experimenting with MVP pattern on Android, using dagger2, Otto eventbus, butterknife, Android priority jobqueue, and using retained Headless Fragment as a presenter. The basic setup is ...
3
votes
2answers
37 views

Find kth element from tail of singly linked list in one pass

I have tried the below program to find (Kth element from tail) of a singly linked list. I have tried to utilize the length field which I am incrementing whenever an item is added into the list or vice ...
3
votes
1answer
39 views

Check if a String is a valid Double

For a class, I need to ask the user for a double. To verify that the number can be safely passed to Double.parseDouble, I wrote ...
1
vote
3answers
136 views

Isomorphic Strings

Two strings are isomorphic if the characters in s can be replaced to get t. Can efficiency be increased further for this code? ...
3
votes
1answer
29 views

Loop for downloading file from the server (in client-server application)

In my client server application, client sends some commands and the server gives the results back. Now my special concern is about the looping for downloading file from the server class, that is ...
4
votes
3answers
39 views

Page Enum with overridden methods for the first and last members

I am managing the changing of views in an Android app using this enum and associated methods. I am particularly interested in the Page enum's use of overriding ...
5
votes
5answers
139 views

Map error messages to conditions

I have a method which checks some preconditions and if everything is fine returns a success response object, otherwise fail with ...
-3
votes
0answers
20 views

Diagonal Sudoku [on hold]

I implemented a diagonal sudoku. Diagonals must not have repetitions My algorithm to check the diagonal was. copy diagonals to arrays left_x and ...
2
votes
1answer
53 views

Doing wire 3D cube without libraries

I was having fun implementing some really basic stuff for 3D graphics. See what I came up with: Matrix.java: ...
1
vote
2answers
214 views

Utility class for an HttpURLConnection

I am creating a utility class to do an HttpURLConnection. I want to make this class generic as in I pass the URL and the POST params. It works with any range of ...
4
votes
2answers
226 views

Longest substring with unique characters

Find the length of the longest substring without repeating characters Any comments on my code? ...
2
votes
2answers
98 views

The longest subsequence with specified difference between min and max

As an input you have non-empty zero-indexed array of integers. The goal is to find the longest subsequence (any sequence obtained by removing some elements from A), where difference between min value ...
0
votes
1answer
33 views

Sum of factorial digits [on hold]

I have seen one algorithmic task and I am not sure if my solution is fully efficient. As input to the method you are given positive integer N. And you should return the sum of values of the digits in ...
2
votes
0answers
31 views

Java JSON Stringifier with the Nashorn API

I have written a Java JSON stringifier with the Nashorn API. Since this code is slow, I wanted to ask if I can improve it. My target is the highest possible performance to make it an alternative to ...
-2
votes
0answers
21 views
1
vote
2answers
31 views

Inserting new Node in a Binary Search Tree

I wrote this method to recursively insert a new node at the proper position in a BST. Is it good enough? Can it be improved? It went through a couple of revisions and I still am not very confident in ...
1
vote
1answer
68 views

Parsing a file for an Android device

I am trying to parse InputEvents of an Android device. Background: For an android device we have a utility getevent ...
2
votes
2answers
52 views

Generating classes from enum

I have a system that receives messages. Each message has a type defined. These types are declared in an enum: enum MessageType { TYPE1, TYPE2, ... , TYPE999 } ...
3
votes
2answers
48 views

Resource caching in Java with soft references

I'd like to cache some heavy resources locally. The goal of this implementation is to have be able to load resources for an unknown amount of time and then keep them in memory and finally evict them ...
2
votes
3answers
128 views

Thread-safe Iterator wrapper

Aside: This code assumes a class Option that can be Some or None to represent the presence (Some) or absence (None) of the value it contains. Haskell calls it Maybe. Here is my first pass at ...
1
vote
0answers
52 views

Recreating pong

Github is a link to all my code and the working JAR file. I have been learning LibGDX and attempted to make a working Pong game, I am new to this and would like some pointers on where I could improve ...
7
votes
2answers
369 views

Sum two linked lists

Write code to sum two numbers represented by a linked list. The digits in this linked list are in reverse order. eg. (9->2->3) + (4->8->2) = (3->1->6) Any comments on my solution (especially ...
30
votes
3answers
3k views

Sorting millions of integers

Last Friday I was hit with a sorting interview question that I never really had to deal with. Develop a your own sorting algorithm. It cannot use any other Classes for help. It needs ...
2
votes
1answer
49 views

Texas Hold em Poker Hand recognition algorithm and implementation

I am designing an in-depth poker game. I am first focusing on recognizing the strength of a hand given the set of cards. Is the following algorithm suitable for the stated purpose? Am I using ...
0
votes
0answers
7 views

Union Find why use value not id[p] [migrated]

In the following implementation for Union Find: ...
-1
votes
3answers
37 views
-1
votes
0answers
31 views

Physics with bouncing balls [on hold]

I'm trying to create bouncing balls with realistic physics. At the moment, when the balls hit each other, they bounce back in the same direction they were coming from, now, I've searched the internet ...
2
votes
2answers
44 views

Binary Conversion in Java

Before implementing a GUI I tried performing it at CLI first and I also tried to implement it by using calling methods to another class. ...
9
votes
5answers
995 views

Finding the smallest number whose digits sum to N

I tried my hand at a grade XII Board exam program: Given two positive numbers M and N, such that M is between 100 and 10000 and N is less than 100, find the smallest integer that is greater than M ...
3
votes
1answer
34 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 ...
0
votes
0answers
16 views

Evaluate Postfix expression [closed]

I am trying to evaluate a post-fix expression using stack. the code is below ...
12
votes
2answers
269 views

Localizing an enum in Java

I am currently using an enum in my Android application to display time periods: Weekly Bi-Weekly Monthly Quarterly Yearly I created the enum like this, because I wanted to know the description, ...
3
votes
1answer
42 views

A system for determination of human language from input text:: robustification

This program works, but it's pretty clunky and fragile. I want to make it more dynamic / solid. For instance some of the functionality depends on the order I entered things into an ...
2
votes
1answer
57 views

Extracting ZIP, JAR and EPUB files

I wrote a utility class that is used to extract the contents of a ZIP file to a destination folder. This is a very small class, but it has several practical applications: it can not only be used to ...
2
votes
0answers
36 views

Porting Java semaphore to MacOSX

I wanted to write some more JNI code and decided to (re)implement a semaphore for MacOSX. In order to assert somehow correctness of my implementation I hereby supply a (multi)consumer/(multi)producer ...
1
vote
1answer
18 views

Environment-specific code in @Async mail method with Spring

I have a Spring @Service to asynchronously send emails. The part that seems to be a bit off to me is some code that is specific to our QA environment. We want to send and receive all emails through ...
6
votes
4answers
101 views
0
votes
0answers
6 views

Feedback requests - spring webskite skeleton [closed]

I've been working on a skeleton for the spring framework (without using springboot). It's maybe 90% done. I'm not java pro - I was wondering if anyone could provide some feedback on architecture ...
4
votes
3answers
97 views

Print the number of unique pairs Stored in a HashSet

I'm trying to solve this fairly straight forward challenge: Problem Statement In computer science, a set is an abstract data type that can store certain values, without any particular ...
0
votes
2answers
59 views

Improving code with loops in Java [closed]

I am working in a lemonade stand game in Java I have some conditions to determine the "perfect recipe" I see a lot of repeated code that I am sure it can be improved with a loop but I am having a hard ...
2
votes
1answer
71 views

Populate the list based on which datacenter code is running on

This is a follow on to : Efficiently detect datacenter based on server hostname and return the full path. I have a library which is running in different datacenters in production. I have three ...