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
14 views
Partition a singly linked list using Java - follow-up
This is a follow up to my last question:
Partition a singly linked list using Java
Based on the feedback I received there, I changed the following about the code:
Added a ...
3
votes
1answer
21 views
Creating a triangle
I have two implementation which I modified according to my need to create a triangle or a pyramid like this:
*
***
*****
*******
*********
First ...
-3
votes
0answers
15 views
-5
votes
0answers
29 views
Java find the area of a hexagon [on hold]
Find the area of a hexagon which can be computed using the following formula. \$s\$ is the length of a side.
$$ A = \frac{6 \times s^2}{4 \times \tan(\frac{\pi}{6})} $$
This question is under ...
-3
votes
0answers
11 views
Grade generation using java [on hold]
I am new to this field can you please help me.
I am having a program where user inputs the mark and the grade is displayed according to it.
But without using the if...else condition to specify the ...
1
vote
1answer
42 views
Java Tic Tac Toe
This is the TicTacToe.java program that I've coded. How can I make this code more like a production type of code (except for Lack of Comments Part)?
Requirements: Design the basic Tic Tac Toe game
<...
1
vote
2answers
69 views
Partition a singly linked list using Java
This is my attempted solution to exercise 2.4 in Cracking the Coding Interview.
The problem statement is:
Write code to partition a linked list around a value x such that all nodes less than x ...
-1
votes
0answers
13 views
remaining amount in java code is printing the same value [on hold]
I am writing this code in java and using eclipse as a compiler. I've created a banking program where the ATM dispenses money in the highest denomination (highest to lowest). My issue is how to ...
-2
votes
0answers
12 views
java Code which run node process [on hold]
The following code is running node process that needed to be stops after
40 which I dont get response,The code is working! since Im new to java I want validate if I use threads like I should and to ...
2
votes
1answer
41 views
Brightness adjustment control for multiple UI elements
I have an application that basically exists as a map and some controls. The controls change the look and feel of the map. I have a slider which is used to change the brightness, for example. At the ...
2
votes
2answers
38 views
SQL Query to display minimum prices per country
I have developed a Tender management System sort of code for one of my client. This is the piece of code :
...
1
vote
1answer
31 views
Java string permutations
In trying to compute permutations of a given string, what can I do to further improve the code below for memory and/or time efficiency?
...
1
vote
1answer
64 views
Job queue with threading
On many articles and blogs, I have read that exceptions should not decide flow of your code.
I have wrote the following code using one thread:
...
-1
votes
1answer
34 views
5
votes
3answers
947 views
Give me some change as asked in interview
Description:
The goal in this problem is to find the minimum number of coins needed
to change the input value (an integer) into coins with denominations 1,
5, and 10
The input consists of ...
1
vote
1answer
44 views
Java Stream - Collections - remove duplicates based on string and presence/absence of local date value
I have a list of objects with a string (name) and a local date (date of deletion).
I wish to implement uniqueness on these objects based on:
If two objects have the same name, then I wish the one ...
5
votes
1answer
258 views
Closeable to AutoCloseable converter utility for 3rd party java libs
I made this utility class to convert Closeable instances to AutoCloseable, so that I can make use of the try-with-resource exception handling mechanism of Java7. This is mainly useful for code which ...
1
vote
1answer
63 views
Android RecyclerView holding rows of razzles
I have a RecyclerView that works and everything, and this is how I coded it:
...
3
votes
3answers
197 views
Fractional Knapack as asked in an interview
Description:
Given the Knapsack capacity and the weight and value of some items,
find a way to maximize the value in the given Knapsack.
Code:
...
2
votes
0answers
26 views
+50
Android generic SQL database handler
Starting with the fact that creating the classic database handler in Android is really annoying and it usually takes a lot of time since you have to create one handler for each object, I thought at ...
0
votes
0answers
20 views
Android Login Screen implemented in Model-View-Presenter Pattern
So this is my first time implementing the MVP pattern in Android.
As I understand the presenter should not contain any Android specific code. I am using ...
1
vote
0answers
18 views
Spring MVC validation Multipart file in form
I need make validation of Multipart file in form class. I wrote custom annotation for form class which validate Multipart file. This code works great, but I don`t know if this is a good approach.
...
0
votes
1answer
39 views
How can I extract these similar codes into only one method? [on hold]
I have implemented three ways of Singleton idiom in Java, and now I want to write some test code to see there performance. Here is my code:
...
1
vote
0answers
22 views
Adding to a message queue if more important messages come in
We need to send messages with highest priority first so we use a PriorityQueue for our purpose.
...
1
vote
0answers
32 views
+500
Java web app with JSF - layered and moduled design with DI and no framework
Any comments? I tried to make my code modular and testable. I tried to make use of dependency injection without using any frameworks. All the classes are stateless, immutable and thread-safe (I think)....
4
votes
0answers
59 views
Coin change algorithm
I've implemented the coin change algorithm using Dynamic Programming and Greedy Algorithm w/ backtracking. The description is as follows:
Given an amount of change (n) list all of the ...
8
votes
2answers
422 views
Velocity, Distance and Time Calculator
This is a velocity, distance, and time calculator that I wrote not too long ago. How can I improve upon this code?
...
1
vote
0answers
23 views
Send a volley request in the background every 10 seconds to a server
I created a class called HomeService that extends the android.app.Service. I then declared and implemented a class called BackgroundService which extends Thread. In the run method of the class I call ...
5
votes
3answers
134 views
+50
Android Activity with a RecyclerView inflated by a big ArrayList
This Activity has got a RecyclerView that is inflated with an ArrayList that is ca. 400 Elements.
This is what an Element of ...
-1
votes
0answers
42 views
-4
votes
0answers
27 views
-3
votes
0answers
19 views
2
votes
1answer
31 views
Directed weighted Graph Data Structure in Java
I am beginner in Java. I coded Directed weighted Graph data structure by myself without anyone's help i want to have some constructive feedback regarding my program design, weather my code is perfect ...
2
votes
0answers
21 views
Implementing FusedLocationProvider for more than one Activity in Android
I am trying to implement Google Maps in Android. I am also trying to learn different design patterns.
I want to use location in more than one Activity hence I have used a class named 'GoogleLocation' ...
0
votes
0answers
16 views
How to sort an object array from last to first entry [closed]
I've been trying to work out this method where I insert an object to the next available slot in the array and then try to sort the array from that point till the beginning of it via bubble sort.
The ...
2
votes
1answer
42 views
Implementing a Rubik's Cube timer and scrambler in console
Related, but in C++
I have written a program that generates scrambling algorithms for and times a solving session of a 3x3 Rubik's cube.
Requirements for scramble and timer
The same face cannot be ...
-4
votes
0answers
17 views
5
votes
1answer
189 views
An iterable implementation of LinkedList
I am curious as to what improvements to my code can be suggested.
...
1
vote
2answers
61 views
Implementing a queue using three stacks
This is just for fun so you will see tons of print statements for trouble shooting. I was hoping on slimming this down some and gain new ideas on what I have. This was a challenge question in a class ...
0
votes
1answer
49 views
Postfix to Infix Expression Tree in Java [closed]
So I'm having a difficult time trying to convert Postfix to infix in an Expression tree. I have read many pages about infix to postfix. But not the other way around. I'm able to insert the code as ...
3
votes
1answer
97 views
SpaceWar game in java
I made this game which should imitate a spaceship and obstacles (planets). Move spaceship and try to hit everything.
I will add some others features and functionality (better images or whatever).
I ...
4
votes
0answers
29 views
Communicating upwards from nested fragments in Android
I recently asked this question on Stack Overflow, but now that I have a working example, I would like to have it checked.
I set up the layout like this:
I am going off the idea that parents can ...
0
votes
1answer
87 views
Implementation on “Factory Method Pattern”
I am learning design patterns.
I started learning factory pattern, and also implemented factory method pattern.
So my factory-method pattern classes are as follows:
There are two major parts, an ...
4
votes
2answers
77 views
Generic class to generate combinations
As junior java programmer I am working with Euler project and I would like to create a general purpose class which generates all the combinations from the length ...
1
vote
2answers
79 views
Project Euler Problem #3 in Java - Largest Prime Factor
I have solved the problem and it gives me the right output when the BigInteger has the smaller value, however it kept running for more than 20 minutes with the ...
0
votes
0answers
51 views
Merging results of product searches by category, price, and manufacturer
Following is code which takes three arguments as
String
Map
String
now I already have some predefined methods which return the requirement of both String as ...
1
vote
0answers
28 views
Deque implementation [closed]
I tried to implement Deque for Coursera Algorithms . Can anybody tell anything about code?
...
1
vote
0answers
29 views
Android Internal Resource Reader
I'm not really sure if this is right, so it would be great to have it reviewed.
I'm creating an Android library and made a final class with completely static methods for getting internal resources (...
2
votes
2answers
139 views
Checking for a win in Tic Tac Toe
I'm working on Tic Tac Toe and I want do it for any ROW x COL board with any WIN_SIZE (e.g. 4x4 board requires 3 to win). I've done the ...
1
vote
1answer
79 views
Temperature converter program
Can anyone suggest any improvements? I already applied here the suggestions that was made for my first program (Guess the Number) that I posted.
...