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.
-4
votes
0answers
13 views
Is my do-while loop correct? [on hold]
I want to complete a task, which assigns the variable randomButton a value. At the end, I want to check the value of ...
2
votes
0answers
31 views
Moving buttons is very slow
I have a very simple app which removes buttons and re-adds buttons to certain layouts when a button is clicked. The problem is this process is taking a very long time. How do I speed this process up?
...
2
votes
1answer
22 views
Calculate sum of all the items in array list?
I am setting the sum total of all the items in an array to a text view in android.The values contained in the array are all currency values.
...
-4
votes
0answers
12 views
-4
votes
0answers
16 views
3
votes
2answers
28 views
Batch Processing : Design check with SRP and OCP prinicple
I have to create a batch process which reads data from DB , process it and saves it in db . The batch data is fetched organization wise ( each organization has set of data to be processed) at once.We ...
7
votes
2answers
125 views
Filtered Iterator
I have written a wrapper for Java's Iterator class using Java 7, which is designed to only iterate items that match a certain filter.
When the filter is null, all ...
4
votes
0answers
27 views
Simulation of Multiple Producer Consumer
I am trying to implement the Multiple Producer-Consumer problem. I have made the buffer as the lock to maintain consistency of the system. Does this system actually implement multithreading? How can I ...
2
votes
0answers
25 views
Infix to Postfix Formula Parser Java
I've written a program that takes a mathematical formula as an user input and converts it from infix to postfix.
It doesn't support negative numbers.
The program doesn't depend on the user having to ...
-4
votes
0answers
12 views
First the Image is not going on and it says the applet hasnt started [on hold]
First the Image is not going on and it says the applet hasnt started at the bottom of this applet. Please help me its fursrtating me a lot. And i tried to do this based of this youtube viedo if it ...
0
votes
0answers
20 views
Dictionary operations on a Binary Search Tree data structure?
today I tried to code all the dictionary operations such as Search, Successor, Predecessor, Minimum, Maximum, Insert, Delete etc. for a Binary Search Tree data structure using the Java programming ...
-2
votes
0answers
17 views
Graph - Breadth first search with iterator (Java) [on hold]
I'm trying to create Breadth first search with iterator, but I do not know where this error. Why it does not work?
...
19
votes
6answers
1k views
SHOUTY_SNAKE_CASED NUMBERS
WE_ALL_LOVE_SHOUTY_SNAKE_CASE_SO_I_WROTE_A_PROGRAM_FOR_IT!!1!
Alright, enough of this. This is a rags-to-riches from this question. The pattern is pretty simple, it takes a ...
10
votes
4answers
654 views
Using reflection in a test to check if a private variable is really null after a function, is this okay?
I am using reflection to check if a private variable is set to null after the logout function. This is needed because the getUser function will always attempt to set and return an user if no user is ...
4
votes
2answers
37 views
JDBC connection and retrieval of info
If you are wondering why I ask, it is because I have numerous different methods all with very similar code (the only difference in the code in each method is what is between the generate ...
-5
votes
0answers
15 views
stack order exchanging [on hold]
A stock order is an order to buy/sell a given
quantity of stocks of specified company. Person willing to
buy or sell a stock will submit an order to a stock exchange,
where it is executed against the ...
1
vote
2answers
91 views
Java Utility that converts warc (Web Archive) files into XML files
I have written a program to perform a task, but I'm guessing it is not optimized. I want to know if there are any ways to improve the effiency and performance of this program.
This program reads a ...
6
votes
1answer
46 views
BF Interpreter, Follow-up: ++;++; is now +=2;
Follow-up to: Brainfuck Interpreter: Slower than a Snail?
Many improvements have been added, including:
Remembering where the matching [ and ...
8
votes
4answers
529 views
Array implementation of Java Stack
As an exercise, I wanted to make an array implementation of Stack, including most of the methods from the native Java Stack.
...
5
votes
1answer
57 views
Custom encryption
I made a custom encryption library/class which allows to en-/decrypt Strings with a custom charset. I think you'll get what I mean with that when you take a look at ...
16
votes
8answers
1k views
Writing nested for loops to produce certain output
My task:
Write nested for loops to produce the following output with each line
48 characters wide:
...
14
votes
3answers
625 views
-3
votes
0answers
23 views
graph depth first search and breadth first search with iterator (java) [on hold]
I have this class GraphDirListAdj. I need to change traversalDepth(E orig) and traversalWidth(E orig) to use Iterator with the following "classes" (interfaces): interface Iterator and IterableGraph. ...
4
votes
1answer
34 views
Which loop to use for multiple if statements which serialize objects
I have figured out how to serialize multiple objects, however I am utterly convinced I can use some kind of loop for the if statements below, to avoid duplication. Please can someone advise how I ...
1
vote
1answer
35 views
JavaFX await implementation
I'm debating trying to take a crack at getting something similar to C#'s async-co-routine like nature over on JavaFX.
This is technically feasible since the Quantem toolkit exposes the ...
15
votes
1answer
85 views
21: The number with the curse
The goal of this game is to not say the number 21.
Rules:
You must only say numbers consecutive to the previous said number.
You may say 1, 2, or 3 numbers at a time.
For example:
Player 1 ...
14
votes
3answers
508 views
“Ticker” for game timing
I designed a "Ticker" based on how I imagine Minecraft's tick system works. My ticker calls a method tickRate times a second and provides a Delta Time value (...
6
votes
3answers
152 views
Simple input/output practice
This code is just some exercise code printing questions and waiting for answers. It is working perfectly well as far as I can tell. I would like to know if this code could be considered acceptable or ...
5
votes
2answers
72 views
2
votes
2answers
50 views
Using actionPerformed() to call different methods per radio button selection
My Java is very rusty and I have been unlucky finding a better way to accomplish this task. I have two different methods which get called based on which radio button is selected. Is there a cleaner ...
0
votes
0answers
9 views
Password randomiser: creates the same password [migrated]
The point is to make a password randomiser, but my problem is that my code makes the same password all the time. I have tried all kind of stuff and this is the latest one where I have gotten by using ...
0
votes
0answers
34 views
Custom connection pool : performance
I have a project, that creates a custom DataBaseConnection pool as below:
...
-1
votes
1answer
38 views
Static imports in java [on hold]
Is static imports making my code incomprehensible?
If I have static a variable in a class, and I call it in another class:
...
-2
votes
2answers
77 views
Java spaghetti code [on hold]
How to know if my code is spaghetti or not?
Is this is spaghetti code?
...
4
votes
1answer
43 views
Method to read the number of lines in a web page
Needing a way to read the number of lines on a web page for the purpose of a progress bar the following method is created:
...
-1
votes
0answers
22 views
Java - Looping UI bug [closed]
I've written this really simple console based UI for a project. It seems to work fine but for some reason, it gets caught in an infinite loop somehow once the user inputs a non-Int response to the ...
4
votes
2answers
106 views
Java conversion of base 16 to base 64
I wrote a solution in Java to solve the problem here. I use BigInteger to convert first from base 16 to base 10, then base 10 to base 64.
This seems quite ...
6
votes
2answers
117 views
Using contents of an integer array to print a String
I have written this code that takes input from a file and creates an output file that reports each person's name, percentage of B answers, and personality. However, ...
9
votes
0answers
46 views
Counting paths in an n-dimensional grid that stay within the boundaries
Problem Statement
You are situated in an N dimensional grid at position (x1, x2, …, xN).
The dimensions of the grid are (D1, D2, …, DN). In one step, you can
walk one step ahead or behind in ...
4
votes
1answer
39 views
Calculate Cosine similarity between Multisets
Having read "Effective Java" and "Clean Code" I wanted to apply these principles in a manageable scenario. To this end I refactored a Java library that calculates similarities between strings.
The ...
6
votes
2answers
107 views
99 times drunk on Java
This is a rags-to-riches attempt from this question, based on the popular 99 Bottles of Beer, by (lightly) using Java 8's stream-based processing.
Any room for improvement in terms of readability? I ...
0
votes
0answers
10 views
Get touched event to be continuously active [migrated]
I'm trying to make a game i want to be able to press down on my gamePadUI to keep my character walking. Far as I can tell the TouchEvents only get called 1st time I push down on the screen
I have 2 ...
1
vote
0answers
31 views
Min Heap Sort using Generics
Here is my working code for a min-heap sort using an Array-List. I would like any input as to areas that need additional refining and any areas that are against proper formatting/usage. Although not ...
4
votes
1answer
56 views
Binary Search tree deletion optimization
I have just started implementing Binary Search tree on my own without using any tutorials online.
Please have a look and suggest how can I make code less cluttered and more faster. Right now I am ...
4
votes
1answer
61 views
Conway's Game of Life
Inspired by this post, I decided to try to implement my own Conway's Game of Life.
I started with a non-warping board:
...
9
votes
3answers
337 views
Beer song excercise
I'm reading the book Head First Java and got an assignment to re-create the 99 Bottles of Beer song according to those lyrics found in the URL. I've had to do this with a Java while loop.
...
5
votes
3answers
81 views
Find word in two dimentional array of char
Task: I have two dimensional array of chars filled with random values [a-z] and need to find if the word ala appears vertically, ...
-4
votes
0answers
13 views
1
vote
0answers
24 views
Uploading an image to Imgur
I have made a class what uploads an image to imgur (a service with an API where you can upload images). And then I read the response of the API what contains the URL and the HTTP status code (200 if ...
2
votes
0answers
47 views
Find maximum distance between two adjacent values in a given array [closed]
The following is code I wrote to solve a codility coding test. This scored 77% on correctness & 50% on performance. I need help in improving it further.
Problem statement:
Given a ...