Tagged Questions
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.
2
votes
1answer
34 views
Determining average of integers using quicksort
I was attempting an online problem given on a programming website which asked us to tell us the number of integers in a given list which can be obtained as an average of any two other integers in that ...
2
votes
0answers
15 views
Helper class to send emails with attachments on Android
I use this EmailTools helper class inside an Android app to send data as an email attachment, by calling ...
2
votes
1answer
36 views
Binary HeapSort and Ternary HeapSort implementation
This is my take on binary and ternary heapsort implementation for a university assignment. The code works but I wonder if there are any mistakes or things to improve.
...
4
votes
1answer
29 views
Cron expression validator for Apache Quartz
Not too long ago, I had to create a cron expression for a route in Apache Camel. I had a bit of a struggle to find the right expression. So I made a small program to output the n next valid dates ...
0
votes
0answers
49 views
Is there any reason for copying a byte[] before writing it to OutputStream? [on hold]
This is not my code but I was trying to evaluate code quality of an open source project and one of the first things I encountered is this:
...
-5
votes
0answers
42 views
Java very slow execution of A* Pathfinding Algorithm [on hold]
I am creating a Maze game in java and wants to add a smarty ghost (like Pacman) that move towards user location to catch him. For smarty ghost I chose A* PathFinding Algorithm and found below links ...
3
votes
1answer
79 views
Examining programming laboratory exercise for faculty
I'm developing software for examining programming laboratory exercise for faculty. I have an Error object that can be attached to students work. It can be attached ...
5
votes
3answers
649 views
Efficiently generating HTML CSS table using Java
I am trying to generate an HTML table using Java. I have an object which I am iterating to make an HTML table.
...
2
votes
1answer
69 views
Fractions in Java
Part I-IV recommend code changes as mentioned in link 1, for the initial code given at link 2.
Can you please review the code changes for Part I-IV?
Part I: Constructors (1 point)
Modify the ...
5
votes
5answers
548 views
Simple text DataBase
So I made this simple text database system for storing a list of objects because I hate using other database programs. But I was just wondering what you guys think I could do to make this faster and ...
11
votes
6answers
1k views
Password validation in Java
I just wrote this password validation code function that checks to see if a password will be accepted in AD or not. I'm not sure this is the best way to do it, but for now it works fine. I would love ...
2
votes
1answer
37 views
How to send an email every half an hour if certain condition is met during that period?
I have my below method which will be called every one minute from the background thread.
In my below code, if my unauthorizedCount and ...
5
votes
1answer
73 views
Software Key Generator
I have created a Java program which generates a key (for activating a piece of software for example) my code works correctly however there are parts of it that I know can be improved. In particular ...
4
votes
2answers
33 views
Improving performance in a Webdriver method
I'm testing an application which is not exactly an e-commerce application but which behaves enough like one that you can think of it as an e-commerce application for the purposes of understanding this ...
5
votes
2answers
212 views
Remove Nth Node from End of Linked List
I am solving the well known problem Remove Nth Node From End of List:
Given a linked list, remove the n-th node from the end of list and
return its head. Assume that n is between 0 and the ...
-2
votes
0answers
19 views
Mirror image java [on hold]
I'm looking for at bit help to solve an assignment in my programming course.
I have to mirror an image in BlueJay (java)
I have the following code, but it is missing a little bit.
My instructor ...
0
votes
1answer
21 views
Checking for a double parameter using Big Decimal
I'm seeking a review of correct design practices.
...
-1
votes
0answers
24 views
Generating all possible permutations of the string
This generates all possible permutations of the string. I am also unable to understand the time complexity of this problem. Can someone please explain the complexity to me?
...
-2
votes
0answers
30 views
variables in java [on hold]
I'm currently beginning java i have a question on some code. I know whats wrong with it but I'm asking why i need the .name method instead of just naming each variable in the array (hopefully that ...
7
votes
3answers
107 views
Hangman game in Java
I'm hoping someone can look over my code and tell me if there is anything I can improve. I am not very experienced with Java so I am hoping for some feedback as to avoid developing any bad habits ...
6
votes
2answers
49 views
Performance of speech enhancement code for Android app
I wrote a speech enhancement code for an Android App. The algorithm runs on 256 size frames of voice samples. On my PC the code runs per about 5ms per frame, while on my Nexsus 5 it more like 50ms per ...
3
votes
3answers
76 views
Implementation of a doubly linked list in Java
I'd like to improve this code.
DoublyLinkList.java
...
8
votes
1answer
65 views
Too much fun with EnumMap-related features and lambdas?
I have created an utilities class to handle certain EnumMap-related features, such as creating and converting between ...
4
votes
2answers
204 views
Simple factorial program using recursion
Two concepts I realized I needed to understand and use more are recursion and Exceptions. Thus, I combined both in the following program. Although it began with a focus on using recursion it became ...
-1
votes
0answers
36 views
Naming of methods that perform some actions under some condition [on hold]
I often write such methods to avoid duplication in code and I give them name such as doSomethingIfSomeCondition().
For example:
...
1
vote
1answer
46 views
Follow-up: Find number of times that difference of array values are equals to a number
This question is follow-up to this question.
Sample Calculation
...
0
votes
1answer
27 views
Follow-up: Find sum of number of times that each character of source occurs in the target
This question is a follow-up of this question. The aim of the questions is to find sum of number of times that each character of source occurs in the target.
In the new code, I've renamed the char ...
4
votes
2answers
391 views
7
votes
1answer
45 views
Shady Characters
As part of my familiarization with the features of Java 8, and inspired by this question, I thought I would take the 'Shady Character' problem to 'the next level'.
Find sum of number of times that ...
4
votes
2answers
85 views
Find sum of number of times that each character of source occurs in the target
I wrote the following code in response to this question "find sum of number of times that each character of source occurs in the target", is there any better solution for it?
Analysis
...
5
votes
4answers
257 views
Find the number of times that the difference of array values are equal to the number
I wrote the following code to answer this, but I am wondering if there is any better approach.
For example
If the following array is given:
{10,21,34,45,56}
...
1
vote
1answer
34 views
HeapSort Efficiency
For heap (array based) sort, we need to start at index 1, ignoring the 0th index. If I want to make a static function like
...
6
votes
3answers
301 views
Time to Next Departure
I am trying to find out how many minutes that are remaining until the next train will departure, based on the current system time in Java.
I am so far not familiar with the many aspects of Java, but ...
3
votes
1answer
33 views
Unit testing a servlet in a meaningful way
I have to write a unit test for the method processRequest in the servlet below and I'm wondering if:
It just shouldn't be done.
The class should be rewritten / ...
17
votes
2answers
2k views
Android Flashlight app
This is my first project, a Flashlight application for Android-based devices:
...
0
votes
0answers
4 views
Future proofing fluent-method-chained-DSL test code [migrated]
The current design is a pair of thin fluent-method-chained-DSLs that mix the "traditional" and "enhanced" builder patterns. That's just a fancy way to say some chained methods are optional and not ...
3
votes
3answers
148 views
Is SList class an ADT?
As per the definition given in lecture, ADT is,
With reference to this definition, I would like to call SList class an ADT following 6 invariants:
Multiple ...
3
votes
0answers
85 views
To subclass or to wrap for “default” implementation? [migrated]
I'm creating a toolset in Java consisting of many Natural Language Processing (NLP) tools, such as Tokenizer, POS tagger, Lemmatizer, Sentence parsing, etc.
I want to put all good and publicly ...
6
votes
2answers
270 views
Parallel “wget” in Java
Purpose: write Java program that downloads a list of URLs specified on commandline in parallel (simultaneously), reporting download completion every second.
My solution follows below, please point ...
2
votes
7answers
110 views
Optimization of a String maneuvering oriented program
I've got an interview coming up for which the following is a prospective question:
Given 2 strings, for instance:
John Lennon
Paul ON
delete every character from string 1 which ...
0
votes
0answers
27 views
How to get values to output as a currency? [closed]
I am working on calculating change, and investment rates with java. My code gives me the correct values, but does not display them how I'd like. For the first part, when I calculate the dollar amount ...
9
votes
5answers
299 views
Modeling a Triangle, with a utility method to classify it
Inspired by this question, I played a bit with the idea of modeling a Triangle, and a utility method to classify it:
...
0
votes
0answers
30 views
Values are null [closed]
I am working on a contact list. I've just about got it working, except for two problems. The output value for the user input prints as null and the Email Address output line contains the null values ...
3
votes
2answers
118 views
Calculating sum of manhattan distances in a sliding puzzle
I would like some feed back on a method which calculates the sum of Manhattan distances for each tile in a sliding puzzle to its goal position in the goal puzzle.
Here is the code:
...
5
votes
3answers
347 views
-1
votes
0answers
60 views
JavaSE client: is this how to get a new JPA EntityManager each time? (DAO) [closed]
This class functions, in that the program can be left open for hours and it will still reconnect to the database when the user prompts for a CRUD operation. I've read about DAO, and some other ...
1
vote
1answer
38 views
Group by two lists in one map using lambda
I've got two collections: collection of rules, and collection of keys that can handle specific rules. Key have method ...
3
votes
3answers
135 views
4
votes
2answers
55 views
Efficiency and design of Dijkstra's algorithm modified for connected nodes
I've written an AI (well... it's not really that intelligent) that plays the board game Ticket to Ride. In that game, cities are essentially nodes of a graph, linked together by train tracks (the ...
0
votes
1answer
36 views
Speeding up Mersenne prime generator
I am writing a program to calculate Mersenne primes. This code works, but it is so slow:
...