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.
0
votes
0answers
9 views
6
votes
1answer
26 views
Listview from SQLite
I'm trying to get back into programming by building an app I've had in mind for quite a while. I've created an SQLite database and have managed to get some data in it. I'm trying to display the data ...
5
votes
2answers
72 views
Find no of swaps needed to club identical elements of array together
I have created a solution for the problem as below:
Given a string S consisting of letters 'O' and 'Z'. Calculate the
minimum number of changes required such that all O's are adjacent to
each ...
-1
votes
0answers
11 views
Using MergeSort with BigDecimal [on hold]
I recently accepted the "Java BigDecimal" challenge at Hackerrank.com. For sorting in reverse order I used a modified version of MergeSort. However, in my Merge function I could not find a way to ...
0
votes
2answers
25 views
JLabel formatting on GPA calculator
I am currently working on a GPA Calculator side project over holiday break to become more familiar with Swing, but I find the number formatting is more complicated than in regular Java. At the moment ...
4
votes
1answer
39 views
Caching mechanism for saving a bitmap
I needed a quick caching mechanism to save a bitmap (picture). There was no way I could get the bitmap to the class where I need to upload it to the server so for the sake of organization and code ...
3
votes
2answers
28 views
Closing InputStream of a running process
Let's say you want to extract the output of a console application till you've found a certain keyword. If you have found the keyword the started console process still should be running, however the ...
4
votes
1answer
37 views
Worst case runtime analysis of a string partitioning algorithm
Give all the partitionings of a string s such that every substring of the partition is a
palindrome
What is the time complexity of this solution? And, how can I improve my code overall?
...
4
votes
2answers
73 views
Enums for the four directions
I have walls that I can spawn. They wll move in one of four directions, up, down, right or left. Now I can set, wether the wall is thin, wide, long or short, but the problem is:
Nearly everything I ...
1
vote
1answer
48 views
Java MultiThreading .wait() .notify()
I have been working on a long project trying to understand the basics of multi-threading. The application is supposed to simulate a Shop and a Customer which share a Box and a PayPal account.
...
6
votes
0answers
60 views
String merge sort in Java
This snippet is about sorting a set of strings using merge sort. However, this version is tailored for strings as it relies on lcp values:
Given two strings \$A\$ ...
-2
votes
0answers
22 views
Best way to loop through a Collection Object [on hold]
What is a better way to efficiently loop through an Collection Object.
...
1
vote
1answer
27 views
Seperate out validations from a service and use custom exceptions for entities not found
I am using spring-boot, spring data, and Java 6. Here is an example from a business layer to save student details.
Srvice interface:
...
1
vote
1answer
24 views
Communicating between GUI and controller class using Mediator pattern
I am writing a program that allows a user to interact with MIDI-connected devices. Upon connecting a MIDI device, interactions with this device will update a GUI. Updates to the GUI include what keys ...
3
votes
1answer
43 views
Implementation of observer pattern in web app to monitor an RSS feed
I implemented observer pattern and it will be great if someone can do review of my work and say what should be done better.
What is the problem. Application monitoring rss channel, if there is ...
-3
votes
0answers
29 views
Xor problem in arrays [on hold]
I am trying to solve this problem on hackerrank and it took me a while to get to the trick.
The trick lies in property of xor and the number of times a number appears in a subset of array where a ...
4
votes
0answers
52 views
JavaFX Multi-Page Application Mechanism
I am currently working on a project in Java, and I use JavaFX for the GUI of the System. Currently, I am in the designing phase of the system, where I am designing the look of the system as well as ...
-3
votes
0answers
22 views
What is wrong with my program's algorithm of optimal strategy? [on hold]
The link to the question-(https://www.codechef.com/IPC15P1C/problems/GGAME)
My understanding is that if you xor the values of all the piles and it turns out to be 0 then Alice will lose, else Bob ...
10
votes
3answers
67 views
Reinventing the Math Functions
Just for practice in the mathematical side of programming, I decided to rewrite the math functions, with the addition of the root() function, which the Math library ...
9
votes
1answer
50 views
Fast way to find the most similar color in an array
I have an image and a palette that I want to apply on that image, that is, change all colors of the image to match the closest they can find on the palette. While I have multiple ways to do it, I want ...
3
votes
0answers
108 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
2answers
82 views
Project Euler problem 530 - GCD function is inefficient
Here is a description of Project Euler problem 530:
Every divisor \$d\$ of a number \$n\$ has a complementary divisor \$n/d\$.
Let \$f(n)\$ be the sum of the greatest common divisor of \$d\$ ...
10
votes
1answer
69 views
Maximum element in a binary tree
This method finds the maximum in a binary tree. I have used generics to make this code more usable. However, I am not sure if I have written efficient and good Java code.
This is a method inside a ...
5
votes
3answers
237 views
Java String iterations
I am working with some Java code. Basically I have a wrapper class that holds a string and implements some of the many useful python string methods in Java. My goal here is to implement the Python ...
4
votes
3answers
57 views
File Parsing in Java Using Collection
I have the following requirements:
/* Collection
Write a program that counts the number of unique words in a large text file.
a] Store the words in a collection and report the number of ...
-5
votes
0answers
15 views
Why am I getting NZEC(Non zero exit code)? [closed]
The question was on codechef(https://www.codechef.com/problems/SSWAP2)
...
10
votes
2answers
125 views
Project Euler Problem 530: sum of sum of greatest common divisors
Here is a description of Project Euler problem 530:
Every divisor \$d\$ of a number \$n\$ has a complementary divisor \$n/d\$.
Let \$f(n)\$ be the sum of the greatest common divisor of \$d\$ ...
3
votes
4answers
62 views
Simple grade calculating application
This is a rather simple grade calculating application. Typical assignment or text book project. I've recently finished an introductory course to java, and have been continuously practicing by ...
11
votes
2answers
64 views
Multi-threaded Command Processor
I have written a class that is intended to execute a unit of work to be run in a separate thread. The intended use case for this class is running business logic off of the user interface thread so as ...
13
votes
2answers
83 views
IP sorting program
The purpose of this little program is to:
Separate IPv4 addresses and IPv6 addresses
Will be able to sort them even if the ...
11
votes
2answers
84 views
Dynamic Programming: Fibonacci-like recurrence relation
This is a problem from my Introduction to Algorithms textbook.
Consider the infinite sequence of numbers An|n>0 = (1,1,3,4,8,11,...) defined recursively as follows.
$$
A_n = \left\{\begin{aligned}
...
9
votes
2answers
67 views
Poor man's lazy evaluation in Java 8
I have an class that cheaply imitates a lazy evaluation scheme. The class is for representing a file and additionally providing meta data on the file. Some of the meta-data can be expensive to ...
7
votes
1answer
55 views
Server-side of a chat application
I have written a server-side and the client-side of a chat application. I would like to improve it and I am unsure about my server construct and have absolutely no idea if there is a better way to do ...
4
votes
4answers
458 views
Password Generator, generate password of desired length
While I do know that there are many questions regarding "password generators," I have a different approach and would like to know if it is effective.
1) The below password generator takes on a ...
7
votes
2answers
185 views
7
votes
3answers
300 views
Singly Linked List implementation in Java
Here's my implementation of a Singly Linked List. Would appreciate a review.
...
6
votes
1answer
36 views
Queue implementation in Java
This is my Queue implementation in Java. Would appreciate a review of the code.
...
-3
votes
0answers
21 views
Pattern for returning results based on multiple parameters [closed]
I am working on legacy code where a method is supposed to return results based on mulitple parameters. The pattern used in code works but I'm thinking if it could be improved further. I'll give an ...
11
votes
1answer
83 views
+50
Custom drawString() for game development
About / Background
This is indirectly a follow up from: General Game Loop 3.0, if you prefer to test against it, feel free to. That code is very outdated now though. A test suite is given at the end.
...
7
votes
2answers
109 views
Swing UI for database-to-Excel tool
I'm just wondering what is the cleanest way you can write your GUI/Swing code? Right below is the code I have for my main frame. Could you guys let me know if it looks clean/understandable, and if ...
3
votes
0answers
33 views
Implementing a long-running entity lock
Requirement
I have an entity named ImportData which can be processed once in order to extract data from a file fed to the application.
I need to make sure that, ...
15
votes
4answers
631 views
Credit Calculator
The code has been test to work by the parameters listed below I just wanted to know if there were any details that I missed or blatantly overlooked.
Develop a Java application that determines ...
3
votes
1answer
49 views
Construct a URL given an Enum
I have a below code which constructs the URL given a FlowType enum.
...
7
votes
3answers
274 views
Measuring performance of code using StopWatch
I have created a StopWatch class to measure the performance of any code. I use this StopWatch code in any of my multithreading projects as well.
...
5
votes
1answer
27 views
String parsing and saving ipaddress to file in Java
Following function will parse string resp, which will be like shown in following example. I will get an IP address in the form of a hexadecimal string like ...
8
votes
1answer
90 views
Let's “Iterator” through Fibonacci, forever and ever
Following-up to my previous question, this class is now based on an iterator. The class, instead of forcing the programmer to use up a bunch of memory just to get each progressive number once, they ...
14
votes
4answers
222 views
Student Grades Calculator
I am seeking a review of a previous project I completed in my first term at university. The submission was graded 18/20 however the feedback was minimal and gave no suggestions regarding further ...
7
votes
1answer
126 views
Brute force passwords in Java - follow-up
Here is the updated code. The original question can be found here.
I would love it if you posted more ways I can improve this code. I am still fairly new to Java so I am not entirely sure how to make ...
5
votes
1answer
50 views
Serialization/Deserialization with Generics in Java
I've Implemented a Serialization Utility which Serializes/DeSerializes a class, along with writing JUnit Test Cases for the same.
Please Review the code and Suggest me how to improve it. Particularly ...
7
votes
2answers
114 views
Student grades program
I am just looking for code review and overall critique. I want to know what I can do better and how can I do things more efficiently in Java.
I need particular feedback on the use of my ...