Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [java]

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 bytecode and run in a virtual machine (JVM) enabling a "write once, run anywhere" (WORA) methodology.

5
votes
1answer
41 views

Goldbach conjecture solution finder

The Goldbach conjecture says: any even number greater than two can be represented by the sum of two prime numbers. G(n) = { (p1, p2) | p1 + p2 = n, p1 and p2 are prime numbers with p1 < p2 } ...
1
vote
0answers
21 views

Caret Color and Movment Animation in Swing

I'm developing a new Look and Feel that is based on animation , so i'v decided to make animated text caret too ! the caret works as expected every thing is fine except that am worried about how i did ...
-2
votes
0answers
12 views

needing assistance with a string arraylist with an input [on hold]

im having and issue with my input and storing it into and array how can i input this input and store it into and array and then see that same array? ...
1
vote
2answers
49 views

Input class in Java

I'm a newcomer to Java (I primarily do C# ) and I have to say that they have made I/O handling much more difficult than it should have been. I am accustomed to the scenario where when I need keyboard ...
0
votes
0answers
10 views

Summing buying and selling rate fetched from the web txt

I've got a class that is like a facade, like an engine for my application which is responsible for fetching data from url and summing it. I have got problem with proper names for my methods. ...
0
votes
1answer
53 views

Grouping objects that have the same attributes

A list of objects needs to be grouped. The list is iterated and checked with other objects in the same list except itself. The method People.isAttributeEqual() checks if two objects can be grouped. ...
1
vote
1answer
31 views

Depth-first traversal implementation in Java (by recursion)

I implemented a recursive depth-first traversal, with all three traversal modes in this function. Is this the most succinct way to write the code? ...
0
votes
0answers
20 views

Should my MVC controller create objects from “AddCustomerView” or should I specifically create a “handler” class for this? [on hold]

I have a MVC project with a simple view where the user can add a customer by filling in name and address. The controller checks if the TextFields aren't empty and adds a new customer. I'm wondering ...
8
votes
2answers
2k views

Implementing 3DES algorithm in Java: is my code secure?

I am making a project just for fun that implements the 3DES algorithm in Java. I was wondering if my algorithm looks secure. Is there any advice or feedback you could give me? Do I need to include an ...
2
votes
0answers
36 views

Efficient counting sort for large byte arrays in Java

I have this counting sort for byte values running in linear time with respect to array length: Arrays.java ...
2
votes
0answers
29 views

Having single DAO parent class in an EJB application

I have the following DAOParent class that I use to put connect/disconnect code in one place. Each DAO class in the application ...
-4
votes
0answers
22 views

LeetCode 773. Sliding Puzzle - DFS Logic [on hold]

I tried to solve the LeetCode Sliding Logic Puzzle using BFS and DFS. My BFS solution worked, but my DFS solution did not ... and I cannot figure out why. Here is the original question: https://...
0
votes
0answers
11 views

What is the classes in MapReduce check for stragglers and speculate tasks? [on hold]

From my limited knowledge of Hadoop, I understand that the TaskTracker is in charge of Map and Reduce tasks. I am attempting to modify the decision to speculate slow reduce tasks by (1) checking for ...
4
votes
1answer
193 views

Lazy Loading a Bioinformatic SAM record

I'm currently writing an API to work with Bioinformatic SAM records. Here's an example of one: ...
5
votes
2answers
772 views

Compiling and throwing simple dynamic exceptions at runtime for JVM

I've been using my Dynamic Exception with C# for quite some time already and it saved me a lot of time. This means, I don't have to create a new exception ...
-2
votes
0answers
24 views

Writing classes to withstand future business logic changes [on hold]

I have a processor class AbstractProcessor and multiple concrete classes of the same which gets called in order of the business logic. ...
-2
votes
0answers
17 views

inputMismatchException [on hold]

im designing a class that stores the name of three runners and time it took to finish the race. this class has methods that return the name of the runner in 1st, 2nd and 3rd place ...
0
votes
1answer
52 views

Design a sustainable home tracker and calibrater for power, water, gas to minimize the expense

Problem Statement Following are the various scenarios to be considered Track energy - Track consumption of water, gas and electricity. We should be able extend to capture other type of ...
0
votes
0answers
22 views

Select a value other then currently selected drop down value

Scenario:Select a any other value other then currently selected from a drop down. Please help/review the code and tell me whether this is a efficient solution? ...
1
vote
2answers
88 views

Typed properties in Java

I tried to build a "typed" property system in Java and this is what I came up with: first the class Properties that any class can use as an attribute (demo code in the end). ...
-4
votes
0answers
45 views

Why is return nothing?What is mean? [closed]

public void tableMousePress(MouseEvent e) { if (tablePositions.size() == 0) return; }
5
votes
1answer
52 views

JavaFX Connect Four AI

I made a Connect Four AI with minimax algorithm. It's my first bigger JavaFX project. Any help for improvements would be really appreciated. Board: ...
1
vote
4answers
110 views

Find the thousandth integer without the digits 3, 4, and 7

I have to find the thousandth number (excluding numbers 3, 4, 7) but it's taking a long time, about 9 seconds. I'd like to find out how to improve performance. ...
2
votes
1answer
84 views

Implement Queue using fixed size array

I came across below interview question and I am working on it: Build a queue class with the enqueue and dequeue methods. The queue can store an UNLIMITED number of elements but you are limited to ...
-3
votes
0answers
43 views

What's the complexity of the algorithm to find median of 2 sorted arrays [migrated]

There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be \$O(log(𝑚+𝑛))\$ Here is the code that I ...
0
votes
1answer
21 views

PreparedStatement for closable recordset and connection

Following approach uses more Functional approach (non OOP), each method is passed DataSource as dependency. I've written this piece and I'm wondering if there's something that can be improved. I wish ...
1
vote
0answers
23 views

Implement search for JPA and Spring

I'm trying to implement properly search functionality for database table. I tried this approach: Controller: ...
-2
votes
1answer
35 views

Search customer by ID not printing [closed]

I dont know why my code is not working at all. In my Eclipse there's no errors shown at all. I want to use the id to print the name of my customers, and that's my goal ...
3
votes
0answers
74 views

Java game: select numbered tiles to form a goal sum

This is a homework project (Soft. Eng.) which I have completed. My teacher gave me a 91, but I am unhappy with this grade because my code is quite messy. (Please excuse incomplete Javadoc, the code is ...
0
votes
1answer
37 views

Making Anagram Problem Implementation

Problem Statement Alice is taking a cryptography class and finding anagrams to be very useful. We consider two strings to be anagrams of each other if the first string's letters can be rearranged ...
1
vote
1answer
52 views

MinMax Problem Implementation

Problem Statement: You will be given a list of integers, arr, and a single integer k. You must create an array of length k from elements of arr such that its unfairness is minimized. Call ...
1
vote
0answers
32 views

Java local service with sockets

My goal was to create a Java service on Windows that runs locally and communicates with local programs using JSON. The service should be reliable and robust. The service runs a ServerSocket and ...
0
votes
0answers
19 views

Authentication and auto renewal of an API Token

Following is an https call to retrieve the token, once it's retrieved, it's cached. Callers call the addTokenObserver method that sets a timer based on the token ...
2
votes
0answers
41 views

Code Chef's Cleaning Tables: find the minimum number of tables to clean

Description: Haku has been newly hired by Chef to clean tables at his restaurant. So whenever a customer wants a table, Haku must clean it. But Haku happens to be a lazy boy. So in the ...
0
votes
1answer
62 views

Combinational string search using Java

I wrote a program that receives 2 strings (Input and Search) in the Search string. The sign '+' indicates that if the substring before the '+' exists in the Input string. (The search string cannot ...
3
votes
1answer
52 views

Settings class implementation

I have a settings.txt file with the following format: ...
1
vote
0answers
12 views

split verticle instantiation and configuration loading in vertx application

I am using Vert.x. I've got a single verticle for my application that looks like this ...
1
vote
1answer
58 views

Extract Common Data From List of Objects

I have a list of orders and for some order fields I need get the data that is common among the orders. If the data is not in common, I should indicate null. I collect the common data in a ...
6
votes
2answers
89 views

Rotate array to the left

I am a beginner in programming. To rotate the array to left, I have written the below code. Please point out how to optimize the code and anything I am doing which is not good programming practice. <...
1
vote
1answer
24 views

slow JavaFx PostgreSQL CRUD app with complex object

I've created a JavaFX app to the data about Vessels, Employees and Jobs. The current version works but it is quite slow which I need to fix. I understand the root of my problems but I do not know how ...
2
votes
0answers
31 views

Comparing Java Semaphore versus ReentrantReadWriteLock

In this post, I attempted to compare the performance of two concurrency constructs: java.util.concurrent.Semaphore, ...
1
vote
1answer
43 views

Validating variables/fields from a schema object

Can someone help me to create a generic method that validates common fields/variables comes from multiple objects, if that is possible? The below code validates some bunch of variables/fields from a ...
3
votes
1answer
20 views

Mortgage calculator with Swing for Helsinki MOOC

New to Java, just finished the Helsinki MOOC course. I programmed a basic mortgage calculator as my first solo project and while it works, I have a few questions about coding style: The listener and ...
3
votes
2answers
102 views

Trip planning algorithm

I was presented with an interview question described as follows: Receiving an int[] A of cities, where each A[i] has an appeal ...
1
vote
1answer
59 views

A Java Morse Coder/Decoder basic program [closed]

I have a Morse code coder and decoder here. I'm having an issue trying to remove pieces I have already done from the substring here ...
1
vote
0answers
18 views

Fetching SQL table names and dynamicly insert values

I need to make a UI where I can edit/insert/remove records of my SQL tables through my app. Edits and deletes of records works fine except of insertions when it comes to tables with auto-incremented ...
4
votes
2answers
54 views

Android NDK Low performance

I am trying to write a NDK program for quicksorting an array. However, in my benchmarks C is doing consistently worse than Java, as indicated by my results: Java 1190625 C 1809218 Java 895104 C ...
1
vote
1answer
55 views

Abstracting getter and setter method references for testing

Is the following code easy to understand? If not how should it be changed to be more understandable. The purpose of this is reducing similar code in unit tests. This avoids repeating lines for calling ...
4
votes
6answers
242 views

Text-to-Morse code converter

I created a morse converter from a .txt file. I'm learning java and I created a simple morse converter. Convert only A to Z and 0 to 9 chars. Space char remain for split words in morse-code. At the ...