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
3 views
A Java subclass of ArrayList that supports rotation in constant time - follow-up
(See the previous (and initial) iteration.)
I have more progress on java.util.ArrayList subclass that supports rotations in constant time. See what I have now:
...
4
votes
3answers
127 views
Given an unordered list of numbers, find all pairs that add up to x
I am coding an interview question from Yahoo Software Engineer Intern Interview.
Given an unordered list of numbers, find all pairs that add up to x.
I have a working solution in Java:
...
3
votes
2answers
37 views
Simple Timed Cache by Wrapping HashMap
Just wanted to get a bit of feedback on this simple cache. My use case is to store this data on an Android client to avoid making a high volume of network calls for lookups.
I feel like maybe I ...
4
votes
3answers
287 views
Rotating strings in Java
I have this Java class for producing rotations of an input string:
StringRotator.java
...
3
votes
3answers
41 views
Hackerrank Insertion Sort Part 2
I have started learning Java recently and was looking into the challenges on sorting on Hackerrank.I solved the following problemHackerrank on Insertion Sort.
The challenge was :
In Insertion ...
3
votes
1answer
39 views
Project Euler #127 abc-hits
Problem (Rephrased from here):
The radical of \$n\$, \$rad(n)\$, is the product of distinct prime factors of \$n\$. For example, \$504 = 2^3 × 3^2 × 7\$, so \$rad(504) = 2 × 3 × 7 = 42\$.
...
6
votes
3answers
258 views
A Java subclass of ArrayList that supports rotation in constant time
(See the next iteration.)
I have subclassed java.util.ArrayList in order to be able to "rotate" it in constant time simply by moving a finger index. See what I ...
-3
votes
0answers
21 views
following flow and understanding open source code with debug mode [on hold]
I have downloaded Hadoop and I am trying to understand a little bit how HDFS works on a low level. I have established Intellij so that I can compile and debug the code in an easier way. However, I ...
5
votes
2answers
101 views
Java 8 Stream to produce all permutations of an array using recursion
I want to write a class that returns a Stream of permutations of an int[].
...
2
votes
1answer
29 views
Word Wrapping and Boxing
This was an experiment to take any text and wrap it to a given number of columns. It also wraps
the text in just one box, lets you box multiple blocks of text, and also lets you limit the number
of ...
2
votes
1answer
27 views
Java class that parses Shoutcast stats XML
I have written a Java class that parses Shoutcast 2 stats XML. It uses JDOM to parse the XML. I have only basic knowledge of Java and I wrote this class in about 3 hours. It works, but I don't know if ...
5
votes
1answer
47 views
Comparing two approximate string matching algorithms in Java
Problem description
Given a text \$T[0..n)\$, a pattern \$P[0..m)\$, and a nonnegative
integer \$k\$, report all positions \$j \in [0..n)\$ such that \$ed(P,
T(j - l..j]) \leq k\$ for some \$l \geq ...
4
votes
1answer
35 views
Data Driven (ability) system
I am making a data drive system for creatures, abilities, items, etc. Considering my ability objects I need to create "templates" from the these since parsing them in real time is too slow. I am ...
2
votes
1answer
89 views
Using a Boolean method that never returns “false” to check user permissions
I need to check that a user is allowed to save/retrieve contacts to/from the database by calling a web service, and return an HTTP403 with an explanation if it is not the case.
So for the sake of ...
0
votes
1answer
23 views
Compressing a file using zip or gzip
Write a Compress class defines two static methods, gzipFile(), which
compresses a file using GZIP compression format, and zipDirectory(),
which compresses the files (but not directories) in a ...
0
votes
1answer
20 views
Modifying the affine transform origin in graphics2D
As a project I have written a graphics library for educational use to allow kids at my high school to make Java games without directly dealing with to the Java graphics API. I'm in the final stages, ...
-3
votes
0answers
31 views
I keep getting a Null Pointer Exception after inputting the first name, how can i fix that? [on hold]
I try running the program, but never get past the "name [x] = c.readLine(); portion of the code before getting a null pointer acception, any ideas why? and how can i fix it?
...
1
vote
0answers
29 views
Android SQLite architecture for a task list
I'm writing a simple Android app with a database and am trying to make the right architecture for accessing a database.
MainActivity.java
...
3
votes
1answer
84 views
MazeRunner in Java - follow-up
I've refined a lot of the code from my previous question, and have also decided to include the logic that interprets a given text file. Any advice on how to improve the actual algorithm that solves ...
-2
votes
1answer
28 views
Thread-safe access to multiple objects [on hold]
I have two thread-safe collection in which one's item is other collection's key. Whenever a new Foo comes in, it will be both added to list and map. To ensure thread-safety, both operations are ...
3
votes
3answers
481 views
Reverse words in Java
Short and Spicy question is that If input is how are you and output should beyou are how.
...
3
votes
1answer
74 views
“Destroy the Asteroid” Game
I made this game for my computer science class.
Here is my professor 's requirements:
Write a Processing program that draws a triangle in the middle of the window.
Rotate the triangle when the left ...
1
vote
0answers
33 views
A command line Java program for computing grade point average - follow-up
(See the previous and initial iteration.)
I have refactored the API based on excellent review by cbojar. Also, a honorary mention goes to janos for pruning some unnecessary code out of the transcript ...
0
votes
1answer
20 views
Improving the running time of finding the count of pairs satisfying a symmetric relation
I had an online coding test yesterday. The question is not hard to solve, but I could not achieve the required running time. The question is as follow:
Given \$1 <= M\$, \$N <= 10^5\$ find the ...
5
votes
1answer
53 views
Equivalent passwords ACPC 2014
I am preparing for ACM-TCPC (Tunisia). So I started solving problems from past ACM-ACPC versions. But I got stuck in the Problem I from 2014.
The problem consists of finding the number of ...
1
vote
1answer
75 views
Find pairs in binary search tree in which sum of nodes keys is equal key
There is a task:
Given a binary search tree of \$n\$ nodes, find all the pair of nodes whose sum is equal to a given number \$k\$ in \$O(n)\$ time and constant space.
Please let me know if you ...
4
votes
1answer
64 views
Local variable lookup table
I'm currently in the process of writing my own programming language and the Virtual Machine for the language is responsible for handing all of the local variable scopes.
I need to support the ...
5
votes
5answers
203 views
Removing duplicates in an array
Problem: Remove duplicates from a given array of integers.
I want this method to work without using data sets except an array.
My code is currently \$O(n^2 + n) = O(n^2)\$. How do I shorten this? My ...
4
votes
3answers
123 views
Swing GUI in Java
I'm learning Java at the moment and I'm currently trying to make a GUI using Swing. I've done some reading and people usually prefer and advice to use composition instead of inheritance of e.g. ...
5
votes
1answer
51 views
Game Networking between 2 players
I'm making a game and I want to establish a network connection between 2 players through a server(so the players are clients).
So far all I have is:
...
-2
votes
0answers
14 views
Conditionally throwing Exception [closed]
How do I make sure that some how it doesn't throw exception at first time while checking condition with 1 and allow to check all the condition and then throws the exception related to first Condition ...
3
votes
1answer
44 views
Computer Algebra System implementation
I have got it working in a way so that there is one superclass, MathObject. In this implementation there is only a Constant ...
6
votes
3answers
76 views
A command line Java program for computing grade point average
(See the next iteration.)
I have this command line program for computing GPA (grade point average). Given credit sequence \$\langle c_1, c_2, \dots, c_n \rangle\$ and grade sequence \$\langle g_1, ...
3
votes
1answer
41 views
Parsing an IP address (Bit manipulation)
Given a string representing of an IP address, such as "127.43.23.59", return a 32 bit integer representation of this string. The 32 bit integer is separated into four bytes, where each byte is one of ...
4
votes
1answer
41 views
Gilded Rose Kata
I've just completed the Gilded Rose Refactoring Kata in Java. I took the approach that I would fully characterise the existing behaviour with 100% unit test coverage before refactoring.
Although this ...
-2
votes
0answers
16 views
How to print specific words from a text file ( and only display words that don't repeat) [closed]
It all works except for the iterator part.
I just need it to where the code can only print the words from the text file once.
For example if the text file had the sentence : "A dog ran next to a ...
-1
votes
0answers
8 views
How to extract data and assign to variables from input from clipboard [closed]
I could use your help. As a long term project to help me learn java, i'm creating a bot to play a video game for me. In this example I would like these variables to be set to these particular values.:
...
1
vote
0answers
26 views
Posting HTTP session data on a website
This reads lines from a file, create HTTP sessions and post data on a website. The code is slow, so please suggest how I can improve the performance.
...
-4
votes
0answers
10 views
please help me to create one object for every session and to minimize http session [closed]
// sets the post request as the resulting string
httpSessionMethod.setEntity(se);
...
3
votes
0answers
16 views
Fetch data from co-processor on network in background
My code communicates with a Raspberry Pi (with a static IP address) running on a network. The client sends a signal to the Pi, and the Pi sends back a double (encoded as a string) with the angle ...
3
votes
1answer
42 views
MazeRunner in Java
To test the queue I perfected from one of my CR questions, I've developed a maze program that receives an input maze, starting and end positions, and solves it. I have separate software that handles ...
6
votes
1answer
45 views
Bukkit/Spigot plugin for Minecraft servers
I have created a Bukkit/Spigot plugin for Minecraft servers because I wanted to change the dynamic of mining to prevent people with really bright monitors or the Fullbright mod from being able to skip ...
3
votes
1answer
71 views
Initialize and sum an array in Java using threads
This bit of code initializes an array of any given size where each index corresponds to a thread and a value. That is, index 0 has 0, index 1 has 1, and so on. Then, the values, 0 to n, in the indexes ...
-5
votes
0answers
28 views
java for loop for arithmetic calculator [closed]
I receive an arithmetic expression and split it into 2 arrays, I mad a switch in a for loop to calculate the result, but it gave me a wrong result
...
0
votes
0answers
13 views
External / File-based mergesort (what is MAPPEDSHIFT, MAPPEDMASK, MAPPEDSIZE?) [closed]
I am currently working on a file-based merge-sort implementation and found the topic "External / File-based mergesort" in this forum.
Link: External / File-based mergesort
I tried to run the code ...
5
votes
1answer
130 views
+50
Finding local C# servers on a Java client using UDP and reactive extensions
This program uses UDP broadcast to find app servers on the local network. When a server receives a client broadcast, it sends a port (integer) to the client which will later be used to create a TCP ...
5
votes
2answers
48 views
Mini HTML document builder in Java - follow-up
(See the previous (and first) iteration.)
Now, I have incorporated all the modifications proposed by janos, and, thus, I have the following:
HtmlViewComponent.java
...
1
vote
0answers
27 views
Minimum number of moves to reach the end - follow-up
I need to calculate the minimum number of jumps to reach the end of an array with dice throws.
Array values may be negative/positive:
When positive - move forward
When negative - go back
The ...
8
votes
1answer
70 views
Corrupting Java arithmetic through reflection
Inspired by a PPCG answer, I wrote this code, which shuffles the autoboxing caches of Number subclasses.
This leads to, among other things, outputting ...
2
votes
1answer
41 views
Mini HTML document builder in Java
(See the next iteration.)
I have this tiny library for building HTML pages in Java code:
HtmlViewComponent.java
...