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.

learn more… | top users | synonyms (2)

0
votes
0answers
5 views

Remove adjacent duplicate characters

Introduction This problem is essentially equivalent to this HackerRank problem. The task is to remove all duplicate characters that are adjacent to each other in a given ...
0
votes
0answers
15 views

Project Euler 3: Largest prime factor

How can I improve my code, make it more efficient, and are there any tips you have? Project Euler 3: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the ...
1
vote
1answer
18 views

Vampire number generator

Inspired by Reddit r/dailyprogrammer A vampire number v is a number v=xy with an even number n of digits formed by multiplying a pair of n/2-digit numbers (where the digits are taken from the ...
-2
votes
0answers
6 views

Regarding Image of JFreeChart [on hold]

I have generated an image in png format using ChartUtilities.saveChartAsPNG() method in JFreeChart save that chart in the local path. I am retrieving that chart from local and converting into bytes ...
5
votes
3answers
136 views

ISBN validation with Hibernate Validator

I've written a ISBN-validating annotation. It is to be used in conjunction with Hibernate Validator. I'm pretty satisfied with this code as it works as expected, but I've had to make a design choice ...
1
vote
0answers
18 views

Full screen WebView Android app

I've created a working Android app for my project website. I'm newbie too android dev so please review the code of this app. Any simplification or suggestion to optimize it much appreciated. Thank ...
2
votes
0answers
26 views

NBP currency application

I have a small program in Java with GUI, which is showing NBP currency data in specified tabs. It downloads data from www.nbp.pl using XML format and saving it into Apache Derby database using ...
3
votes
1answer
55 views

Tetris random piece generator

I was inspired by this Reddit /r/dailyprogrammer challenge: Contrary to popular belief, the tetromino pieces you are given in a game of Tetris are not randomly selected. Instead, all seven pieces ...
4
votes
1answer
53 views

Reversing a word or sentence

Was just wanting some general feedback on the below code regarding 1. Readability 2. Structure 3. Efficiency ...
0
votes
0answers
17 views

Animating fragments [on hold]

I have a very specific question regarding animations in Android. If I have a lot of animation code inside an Activity, View, or <...
-6
votes
0answers
38 views

Simplify IF statement [on hold]

Any suggestions on simplifying the following If check Approach1 ...
3
votes
2answers
48 views

Finding median of 3 elements in array, and sorting them

The method medianOfThree returns the median of the first, center and last element in array sorts the first, center, and last element of the array, so they are in ...
-2
votes
0answers
23 views

need to remove last comma in java [on hold]

This is my code ...
2
votes
1answer
22 views

Continuously execute runnables on the UI thread

I need to run a sequence of runnables on the main (ui) thread with a given delay between them indefinitely until signalled to stop. Code: ...
4
votes
2answers
67 views

Find maximum value of Point represented by an Array of values for each coordinate

Suppose there is an array A = {3,2,5}, then points for this array correspond to indexes (i,j) where ...
0
votes
0answers
30 views

Roll dice 10,000 times. 7 and 11 are wins everything else loss. [on hold]

I am writing a program that rolls a pair of dice 10,000 times. If they total 7 or 11 it is considered a win. Every other total is a loss. Need the out put to state the number of wins, losses and the ...
-3
votes
0answers
22 views

Project Euler Problem 21 - Amicable Numbers - JAVA [on hold]

Help Debugging please. Program won't stop. ...
2
votes
0answers
40 views

Interactive Android AppWidget collection to populate activity on click

I recently developed my first appwidget for Android, and it works really nice. I basically created a collection widget and use a Loader to retrieve the data from a database, and when a user clicks on ...
5
votes
2answers
43 views

Sieve of Eratosthenes with a Swing UI

I'm fairly new to Java. I want to divide my code into 3 classes. First class to contain my GUI, second to compute the algorithm and third class to write results in my file. I have the code working but ...
4
votes
2answers
102 views

Poisonous Plants

I have solved the following problem. My code works but Hackerrank says that I can do faster: There are plants in a garden. Each of these plants has been added with some amount of pesticide. ...
-2
votes
1answer
44 views

Return whether there are 2numbers or 3 numbers in an array that add up to specific given sum [on hold]

Need to find 2 numbers or 3 numbers from an array of integers. I have methods for both. I am not sure if this is the best approach to do so. ...
-4
votes
0answers
18 views

connect same attribute in another classes in java [on hold]

I have some problem here and I don't know where is it in code here there are 3 classes and many attributes actually in class Registration there are uniqueStudentID same in class Student and courseCode ...
7
votes
2answers
326 views

Validate whether a ransom note can be made from a dictionary of words

For simplicity, it is checking whether the characters in a string (that needs to be created) are present in a larger string (dictionary). Would a character array of the letters make sense here, or ...
3
votes
1answer
37 views

Extending functionality of org.springframework.batch.item.file.transform.DefaultFieldSet

I would like to be able to set token values (defaultFieldSet.tokens) and names (defaultFieldSet.names) on ...
0
votes
1answer
73 views

Producer-Consumer issue in a multi-threaded Java environment [on hold]

The scenario which I'm trying to implement: This class tests the Worker class. It invokes the run() method of a Worker instance....
1
vote
1answer
50 views

Tight coupling in using call back method

I am using below code and for result i am using interface for call back purposes. ...
4
votes
3answers
79 views

Finding the frequency of an element in a sorted list of integers

1> Input: Array of sorted integers and an element to check the frequency for. 2> Output: Frequency of the element ...
2
votes
2answers
54 views

Finding the Least Common Ancestor of a Binary Tree

Input a binary tree (the root node) and 2 other nodes that need to be assessed for finding the least common ancestor (LCA) Code: a. Finding the nodes first with either ...
1
vote
1answer
48 views

Multithreaded Producer-Consumer pattern

I have Producer Threads A, B and C producing 3 different types of events Events A, B and C respectively. The Consumer thread can ...
2
votes
1answer
74 views

Iterative solution for generating all permutations of a string

I know the runtime for generating all permutations is supposed to be \$O(n!)\$. I'm not sure if the code I wrote for it runs in \$O(n!)\$ though. I'm having trouble analyzing its runtime. The ...
1
vote
0answers
79 views

Code that checks input for calculator app

I made an Android app, a calculator, that uses buttons for input, Android keyboard is turned off. I have a block of code, that handles the input to string and checks for some things at the same time. ...
3
votes
1answer
69 views

Connect Four in Java for two human players

Connect Four kinda caught my eye, and I decided to start from the very basics. Here I have bare-bones implementation for playing the game between two human players on the command line: Board.java <...
-5
votes
0answers
42 views

Explain this program [on hold]

...
3
votes
1answer
42 views

Writing a byte array image to disk with an automatically generated filename

I have the following code that that writes large images to disk. My application server is running out of memory and I'm wondering if I could somehow optimize the following: ...
5
votes
2answers
146 views

Unexpected Low FPS while drawing images

I am in the process of making a game, and during this endeavour, I have come across problems maintaining a good frames per second while drawing my sprites. When I draw my background image, my frames ...
0
votes
0answers
14 views

The same object as parameter of function and returned [closed]

I write the question for my fellow worker (I want to send him a link with the question and answers). I would like to ask you about arguments you have that the code below is bad. It is purely C++ code ...
3
votes
3answers
72 views

Optimizing time and space complexity of recursive solution on string manipulation

Given a string, compute recursively a new string where all the lowercase 'x' chars have been moved to the end of the string. ...
2
votes
2answers
56 views

Circular Singly Linked List using Java

Please review my implementation of Circular Singly Linked List ...
5
votes
2answers
38 views

Search files from large directory and sub-directories

Essentially I have a large directory with many sub-folders and different formats of files. It reads through XML, JAVA, .txt, etc, in search of a selected String inputted by the user. The results ...
-5
votes
0answers
15 views

Improper Output [closed]

So this is a problem i have been working on for ProjectEuler #7 where the objective is to find the 10001st prime number... My code returns the number which comes just after the required output ...
2
votes
1answer
43 views

Standard Test methods for checking values in Lists, Maps etc

I needed to check the values in various Lists and Maps. In my case, the various types of Objects that needed checking were of four types: String ...
3
votes
1answer
30 views

Unit tests for custom Map wrapper

A while ago I asked for a code review of my automatically keyed map and I have recently had the time to get around to writing some unit tests for it using JUnit4. The test ensures that all of the "...
-1
votes
0answers
23 views

Rock Paper Scissors game that simulates one random play and one consistent player [closed]

This is my homework for my CS101 class, I'm not looking for an exact answer, just some guidance please! The program is supposed to simulate Rock Paper Scissors where one player chooses completely at ...
4
votes
2answers
53 views

Flood-clearing routine for a JavaFx Minesweeper

I really hate copy and pasting my code from one method to another. It signals something in my brain, "This could be done either more efficiently or more readable". This is used in a minesweeper ...
-1
votes
1answer
49 views

Searching into a contact list

I am performing search in a contact list using linear search with complexity \$O(n)\$. Please suggest me how to improve search strategy in my code. ...
1
vote
2answers
43 views

Create a calendar application to check the scheduling conflicts of meetings

The purpose here is to find if there is a conflict in the given set of start and end times of the meeting time slots listed. Input: Start and end times of meetings Output: True / False for conflicts <...
0
votes
0answers
10 views

Python api for an existing Java API [closed]

I am new to python and I have to design a Python API(version - 2.7) similar to an existing Java API Python version - 2.7 The Java API is as follows There is a Process interface ...
2
votes
3answers
55 views

Sorting a list by the modulus of 3

The input is an unsorted array of integers. The output should be an array of integers sorted based on the modulus of 3 (or any other number). It begins with all integers conforming to Integer % 3 == ...
2
votes
2answers
61 views

Print max occurring character in a String

This prints the character that occurs the most in a given string. Input: String of word(s) Output: Max occurring character ...
0
votes
0answers
33 views

How memory-efficient is my sorting algorithm? [closed]

I'm wondering how space inefficient the algorithm I created is, (I know why), and how that makes an algorithm like this obsolete compared to RadixSort. If I had thought of a way to make this more ...