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.
1
vote
0answers
9 views
New thread each time a message received?
My application needs to listen for incoming messages on three sonicmq topics.
I have requirement : Everytime a message is received, i should wait for 5 seconds and ...
1
vote
1answer
27 views
Know the limits of an image after rotation
I have an image which I know the number of rows and the number of columns. I would like to calculate the limits of the new image after a rotation.
...
3
votes
0answers
28 views
Are AVL trees equal?
I was inspired by this answer and decided to implement an AVL tree with the methods equals and hashCode as if I was asked to do ...
6
votes
1answer
34 views
Manually parsing HTTP response header
Due to some constraints I had to manually parse an HTTP response coming out of a stream.
I could not use buffered reader or scanner because the perform buffering and end up buffering bytes beyond the ...
3
votes
2answers
30 views
4
votes
2answers
78 views
Java Implementation of Sieve of Eratosthenes algorithm
I previously asked about my implementation of the Sieve of Eratosthenes algorithm here.
After looking at all of the feedback, I have reworked the code to make it significantly more efficient. ...
0
votes
0answers
22 views
Event Aggregator Pattern Decoupling
I have an Android application that is using an EventBus architecture with publishing and subscribing events. Usually this is ...
-4
votes
0answers
54 views
I want to get rid of the switch [on hold]
I'm developing a web application based on Spring, JSP, Hibernate. I want to hear your opinion about the code. on the web form has a filter emails
...
4
votes
2answers
65 views
Printing gitignores
I have written a simple program in Java 7 to write the .gitignore of different file types:
...
4
votes
2answers
180 views
E-mail MIME message parser
As part of a larger Java application I'm working on, I have to retrieve emails and parse the data for the emails' content (subject, date, text, attachments, sender). In the method below, I pass a ...
6
votes
1answer
42 views
Ultimate Tic Tac Toe A.K.A. Tic Tactics
My attempt at this challenge., incorporating lessons from this question, which turned out into a much bigger project than I anticipated, but it works. I'll definitely be refactoring most of this in ...
2
votes
0answers
46 views
Generate longest subsequence valid parentheses [on hold]
I was trying to generate the longest parentheses given a string:
Given a string containing just the characters '(' and ')', find the
string of the longest subsequence valid (well-formed) ...
2
votes
1answer
47 views
7
votes
1answer
56 views
Designing yet another coffee machine, Lombok style
After reading Designing a coffee machine, I decided to implement the same problem as an exercise to get to know Guava and Lombok.
I used the problem statement from the given question:
Design ...
1
vote
1answer
26 views
Implementation of Euclidean algorithm
I have made an implementation of the Euclidean algorithm in Java, following the pseudocode shown below.
As far as my knowledge goes, I can't find a way of making this more efficient.
I have looked ...
1
vote
2answers
19 views
Counting Bloom filter library in Java
This snippet is a counting Bloom filter supporting removal of elements as well. Instead of a bit vector it maintains a vector of "bucket counters". Also, the API supports well taking your customised ...
2
votes
0answers
46 views
Project Euler: Autorun problems
I've found that it's a huge pain to have to write the boilerplate code for each Project Euler problem I write (timing code, main method, what about running every problem instead of just one?). So I ...
-1
votes
0answers
14 views
0
votes
1answer
37 views
Working with Exceptions Exercise
The task:
There is an AccountManager that makes transfers. It receives 2 arrays of the same size: accounts and sums. They need to be transferred to the accounts ...
5
votes
4answers
153 views
Finding the most common character in a string with a hash map
I created a method for finding the most common character in a string (using HashMap):
...
7
votes
3answers
763 views
Game server packet handler
I am developing an online game and my code is getting pretty hard to work with. I would appreciate any suggestions how to clean it up or make it simpler to work with. Thanks for any suggestions.
...
3
votes
1answer
26 views
Directed graph path enumerator in Java - follow-up
I have refactored the graph path enumerator. DirectedGraphNode was not changed, so refer to the link above in case you want to have a look at it. The node type is ...
3
votes
2answers
32 views
Skip-List that uses a Singly-Linked-List implementation
I've implemented this skip-list yesterday, and I'd like suggestions on how to improve this code, and my coding practices.
...
5
votes
1answer
54 views
Java calculator using postfix conversion and evaluation
I'm trying to create a program that converts infix expression to postfix (using stack) and evaluate the result of the postfix expression. I already have a solution that works, but I feel that it's ...
1
vote
0answers
20 views
Handling screen rotation with volley request
To handle screen rotation when performing a volley request, I've written this code:
...
-1
votes
0answers
22 views
Queue consumator
I am consuming messages from Kafka (a queue). There are multiple consumer which are reading. What do they do?
They simply read message as a String, parse them and ...
3
votes
0answers
35 views
Multithreading readied Median Filtering
So I've been confronted with a rather simple problem in the Java chat on Stack Overflow. It's about doing a median filter with a sliding reference window.
For the purpose of the task we can assume ...
6
votes
2answers
104 views
Simple Mastermind game in OOP form
I'm currently learning Java. I'm trying to get a good grasp on determining what becomes a class. I've started translating old games in to simple Java programs.
I'm looking for any critique of use ...
2
votes
0answers
36 views
Select two numbers from interlaced blocks of numbers
Select one of two number selection strategies and select two numbers
using that strategy.
The strategy is selected using an enum implementation of the strategy
pattern.
Strategy one: ...
5
votes
1answer
72 views
5
votes
2answers
109 views
Merge k Sorted Arrays
Please review my answer for this interview question:
Merge k sorted arrays, using min heap.
...
0
votes
0answers
32 views
Java Interface implementation [on hold]
I am working on an assignment in my Java class that requires me to implement methods in a Product Database Implementation class. I have populated the methods per instruction (I believe) and would like ...
-2
votes
1answer
74 views
Java code needs reviewing [on hold]
This code technically works, however I endeavour to know the correct way to structure this? If possible could you explain where code could be improved, I am very new to this and aspire to learn as ...
4
votes
2answers
66 views
Directed graph path enumerator in Java
I have this iterator class that expects in its constructor two directed graph nodes, source and target, and upon each ...
2
votes
2answers
80 views
Merge two lists in Java and sort them using Object property and another condition
I have two lists List<Person> list1 = new ArrayList(), list2 = new ArrayList(); (Not the same size), of the class Person:
...
2
votes
2answers
39 views
Adaptive counting sort for integer arrays in Java
I have this adaptive counting sort for integer arrays. Basically, it maintains a doubly-linked list of nodes. Each node knows its integer \$a_i\$ and contains the counter describing the number of ...
5
votes
3answers
74 views
Simple Java addition calculator
I made this simple addition calculator in Java and I'm wondering how I can improve it.
...
-1
votes
2answers
51 views
Extracting a date and time from a log file
I am trying to make my code as legible as possible, and today I wrote the following snippet and I'm unsure as to whether it can be improved in an obvious way. There's always room for improvement, of ...
1
vote
1answer
23 views
A safer way to return a generic indicator object indicating failure
I'm writing a singly-linked list that implements the List interface. I decided going in that I'd try to implement every method as an exercise; even the optional ...
3
votes
2answers
76 views
Connect Four game in Java
I was wondering if you guys could point out any mistakes I've made in this program, and how to improve the code. It's a simple console-based Connect Four game. You use 0-5 to place your piece in the ...
-1
votes
0answers
30 views
3
votes
1answer
40 views
Fastest way to change the HSV value of all pixels in a bitmap
I want to change all the pixels in an image to have the same value, in terms of the HSV colour space.
At the moment I'm running the following code:
...
-1
votes
1answer
37 views
Shortest path in dag saga: Dijkstra's algorithm [closed]
I have this Dijkstra's shortest path algorithm:
net.coderodde.graph.pathfinding.AbstractWeightedPathFinder:
...
1
vote
1answer
37 views
Is a Timer the best way to achieve recursive in Android?
I'm changing the Viewpager items programmatically using mViewPager.setCurrentItem(position); with a regular interval of time recursively. Please tell me if this is ...
0
votes
1answer
36 views
TableCellEditor for multiple columns
Is this the best way to do this?
edit:
I am wanting to use a cell editor and a DocumentFilter to prevent the user from entering certain characters into the table cells. The columns are as ...
10
votes
5answers
1k views
Marijuana information program
I made a simple marijuana information program in which I give the user a list of strains and give the user information about it, like: effects, medical, negatives, and its cannabis type ...
-2
votes
2answers
59 views
Rounding and truncation in IntRange.contains(Object o)
I made a Range class (like an Interval) that takes Integers and implements ...
2
votes
1answer
19 views
Java port of Titlecase
I have a port of titlecase, originally in Perl and ported to other languages such as JavaScript and Python.
...
0
votes
1answer
10 views
Java Loops and UIs
I've always found coding UIs in Java very inefficient, and hopefully this is because of my misunderstanding. Here's a great example.
I have a UI class which is returning the String "Hours", which is ...
0
votes
1answer
39 views
Inserting data into an SQLite database
I've execute this code in Android for inserting 100+ rows in SQLite database.
My current approach takes more time to initialize the database.
...