Stack Exchange Network

Stack Exchange network consists of 174 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.

0
votes
0answers
7 views

Object-Oriented Breadth-First Search Implementation

My goal is to write a GUI application where a user can create a maze and select an algorithm. The passage of the algorithm from a selected start and end point should be visualized. The following ...
2
votes
0answers
24 views

Chess move validator

I have written code for making a Chess Validator, which will validate the moves of a chess game. There is a Main class which is taking the input from the user, about the move. Problem The board is ...
-3
votes
0answers
7 views

How to store a range of generated numbers using IntStream to a text file [on hold]

I wrote a program to generate a range of numbers using IntStream (java 8) but can seems to figure out a way to store the generated numbers into a text file. I know how to store Strings to a file but ...
0
votes
1answer
13 views

Incrementing time in a discrete-event simulation of a supermarket queue

A method has been written that increments time in minutes that simulates how much time it takes to process item in a supermarket queue and if there is an empty queue, skip it and loops around to find ...
1
vote
2answers
22 views

SPOJ Adding reversed number in Java

I just started to practice for competitive programming and just started to solve the most solved problems on SPOJ. This is what I made for ADDREV: Adding reversed numbers in Java (https://www.spoj....
0
votes
1answer
21 views

Battleship Game in Java

I wanted to make a very simply Battleship game in Java, any feedback is welcome. Nevermind the getters / setters. Just assume they are there. ...
0
votes
1answer
21 views

Insertion sort algorithm in Java

I have tested this code and it yields the expected outputs, but I want to verify if I have applied insertion sort algorithm correctly or not. ...
-1
votes
0answers
27 views

Cleaning up Sequential Master Update [on hold]

I'm creating a version of the classic sequential master file update in java. There's some problems with it that I'm trying to clean up. Here's the code: ...
0
votes
0answers
23 views

Templated JSON parsing methods that work with an element or elements array

Consider the following two Java methods. The first takes a JSON string representing one element, the second representing multiple elements. gson.fromJson() can be ...
0
votes
0answers
13 views

adding jms in the rest api flow

In my spring boot app, I am trying to fit in the sender and receiver logic for JMS queue as described here I've put the content of "Sender.java" and "Receiver.java" classes from the above ...
3
votes
1answer
38 views

Swap Elements in Array if first characters match but only once per first character

This is my solution to CodingBat problem p150113. My Java knowledge is from 2011 and I'd like to know if this is still the optimal way to approach such a problem. and if my code is clean and ...
0
votes
0answers
11 views

Make lambdas concise using enumerations? [migrated]

Generally, we are looking to create a logging framework that can target human readable output as well as various structured data formats. So, a goal is minimizing code duplication in packaging the ...
3
votes
3answers
80 views

LeetCode Problem 66 : Plus One

I have started practicing problems in leetcode and I solved the following problem on LeetCode. The challenge is : Given a non-empty array of digits representing a non-negative integer, plus one to ...
2
votes
1answer
39 views

Word Chain Implementation follow up

it's hard for me to implement all those features that were suggested, i did so many thing wrong. can you please review this update on my code, concerning OOP, clean code, and maybe an eye on the ...
1
vote
1answer
33 views

Token generator for Valve Data Format parser in Java

I'm looking to parse a reduced subset of the Valve Data Format (VDF). It is similar to JSON, allowing representation of key-value collections (maps) with arbitrary recursion. As a small example: <...
-1
votes
2answers
46 views

Refactor multiple if statements while creating object [on hold]

I've got a class with few fields: ...
-1
votes
0answers
20 views

Null Pointer Exception based on HashMap [on hold]

I am getting a Null pointer exception despite instantiating a general HashMap with constant values. I intend to track inventory of various car types in a car rental service; with car type serving as ...
-2
votes
0answers
20 views

Calling Salesforce Live Agent API in Java [on hold]

I haven't used the objects in the java.net.* library before. This is all taking place in the run() method of a subclass of ...
4
votes
1answer
90 views

Word Chain Implementation

The idea originaes from the CodeKata19, find a word chain for two words of a wordlist example 1 turning lead into gold: ...
1
vote
1answer
29 views

A simple Java class for implementing code stop watches - follow-up

I have received a nice answer for this post. Now, it is my attempt for some improvement: ...
1
vote
0answers
26 views

Java: Note for monitoring buy/sell item list

I'm making note where you can add items that you buy or sell, any suggestions? ...
-2
votes
0answers
18 views

Shopping List Creation [on hold]

For my coding class I have to build a shopping list by having the user enter the number of items they need and then each item (one at a time). I then have to output the final shopping list in a multi-...
-3
votes
0answers
12 views

Trouble reading and printing content of my text file in Java Main Method [closed]

I have a text file shown below with different input types on a line that I am trying to read accordingly as shown below. I put the text file "Vehicle.txt" shown below directly in the src folder of my ...
1
vote
1answer
54 views

A simple Java class for implementing code stop watches

(The next iteration: A simple Java class for implementing code stop watches - follow-up) Here is my attempt at more convenient benchmarking (yes, this time I am aware of JVM warmup, etc.), and it ...
4
votes
2answers
71 views

Follow up Implementation on Monty Hall Simulation

I have taken your inputs on my original question and formed a new implementation of the Monty Hall Simulation: Again keep an eye on CleanCode and OOP The Price to be won: ...
-4
votes
0answers
37 views

How to do it? in java [closed]

please help me how to change decimal number in string like string 12.345+34.567=46.912 ...
3
votes
2answers
76 views

Printing out a table in console

This program prints out a table in the console. Suggestions for improvements are welcome. Example output ...
0
votes
1answer
15 views

Generate n appointments in the next m months

I work with an API where I need to write code to generate n appointment dates in the coming m months (from today). For the purpose, I write a Random date generator class provided. One condition is I ...
0
votes
0answers
32 views

Split data equally to Thread in java

Is this efficient way to split the record which is comes from database? So that the thread will process the record based on the start and end points. Step 1: Get the total number of records from ...
1
vote
1answer
33 views

POSIX-ly finding a specific Java process

In this code I find a list all of the running java processes and give the below function a name to look for, it will do its best. But since I find my approach a ...
2
votes
1answer
46 views

Calendar holidays to XML

We are writing program which makes XML file which is a calendar with all free days in Poland (Saturdays, Sundays, and all hollidays). We tried to write this code as readable as possible so probably no ...
1
vote
2answers
45 views

Simple war scheduling algorithm in Java

Let \$\mathcal{C} = \{ C_1, \dots, C_n \}\$ bet a set of \$n\$ different countries. We associate with each country \$C_i\$ with its potential \$P_i\$. We choose a specific country \$C_e\$ in \$\...
0
votes
1answer
35 views

Bowling Game Kata

I wanted to practice my programming skill and I started solving exercises from kata-logs site. The exercise: The game consists of 10 frames. In each frame the player has two rolls to knock down ...
-4
votes
0answers
18 views

java variable not expected result [closed]

my code is based on a form in a servlet, issue is with java the bmr is not returning the appropriate answer ...
3
votes
1answer
61 views

Reference service for a cache

I'm using JDK 11. This is my code: ...
1
vote
0answers
43 views

Snake animation in Swing

I'm developing a simple Snake game in Java using Swing. So far I made the snake animation which is troubling me: when the snakes moves it seems like it starts to lag for no reason, but when I move it ...
0
votes
0answers
47 views

Please check my HTTPServlet route parsing extension for quality

Please critique my codebase https://github.com/davidbyng/acme-simple-servlet-extension ...
3
votes
1answer
85 views

Clean Code / OOP on Monty Hall Simulation Implementation

can you review the this code for the Monty Hall simulation, mainly on the aspects of OOP and CleanCode ...
3
votes
3answers
62 views

Simple boolean gate with two TriState inputs

As part of a code review I came across this isDummy(a,b)-Method and the question, whether it is more readable as a conjunction, or a disjunction: Original snippet: ...
0
votes
1answer
37 views

Usage of static block vs. direct static variable initialization [closed]

Suppose, I have a data access layer class, where I want to specify database connection parameters. Usually, I do it as static variables and initialize it right after definition, e.g. see ...
4
votes
1answer
297 views

Simple directory monitoring and processing file on appearance

Currently I am working on some kind of mechanism which will be able to monitor directory and when file with extension .pdf appears I need to mock some kind of ...
2
votes
1answer
42 views

split items of batch into multiple categories

I have a batch job that contains a lot of items. I need to split these items into 4 categories - 1,2 category should be moved to a separate jobs as is; ...
1
vote
2answers
75 views

Item class/system for RPG/DND type game

Thanks for the enormous response on my last question! I've returned with another question, hoping for more insight. I'm developing an Item class and system, and I ...
3
votes
2answers
74 views

Find the longest sub string of a word after concatenation of given words array

An Array of N words is given. Each word consists of small letters ('a'-'z'). Our goal is to concatenate the words in such a way as to obtain a single word with longest possible substring composed of ...
0
votes
2answers
61 views

Servlet filter which detects if the authenticated user is a service account

My concern with this code is that I am forcing execution repeatedly through the same pathway for the sake of a readability that I'm not convinced by. It's a servlet filter which detects if the ...
0
votes
0answers
48 views

Find the smallest subarray with sum greater than a given value

Given some array, find the smallest subarray with a sum that is greater than a value given. So for instance, given this array: {1, -4, -45, 6, 0, 19, 16, 17} ...
14
votes
5answers
3k views

Player class for RPG/DND type game

I am recreating a game that I used to play on the Nintendo DSI, 'Dragon Quest IX'. I've made a player class, but have run into a code efficiency issue. When the ...
2
votes
1answer
59 views

Stopwatch utility class in Java

Looking for input on my code for a Stopwatch utility written in Java. ...
2
votes
2answers
162 views

Mr. Muffin's ball-passing game

I have an assignment to solve this problem. There are a total of 18 test case files, 5 of which I have failed due to exceeding some time limit on the script and I am unable to verify if there are any ...
1
vote
0answers
15 views

Appium automated tests for manipulating checklists

I am new to automation. I have automated few test cases for a mobile app using appium and wanted to know the areas where my code can be improved further. ...