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.

Filter by
Sorted by
Tagged with
-1
votes
0answers
11 views

Standard practices for employing Java Builder design pattern

I am in the process of using Java Builder design pattern to instantiate a class that has optional member variables and need some suggestions on the standard practices. The code is as below: ...
0
votes
0answers
15 views

program to display summary of results, Java [closed]

I've written a program for my class that takes user input on state names, and returns the state bird and flower. at the end of the program, I need to print a summary of the results, and I can't ...
1
vote
1answer
106 views

Comparing two simple distance calculating algorithms

Is the single method printMaxDistance_a or the two methods printMaxDistance_b AND ...
3
votes
2answers
58 views

Java 8 use of optional

I have two methods I'd like to improve using optional and any other tool, ...
1
vote
1answer
39 views

A better cryptography process

I am experimenting with cryptography and I was wondering if somebody has some suggestion how I could improve my code and methodology. I want my process to generate more securely the cryptography ...
2
votes
0answers
36 views

Calculating every possible answer given a set of formulas

Problem Given a set of formulas (AKA "Rules"), get a list containing every possible answer that does not break any formula. Formula variables can have a maximum equal to the number of characters. ...
-3
votes
0answers
27 views

Java - Trying to create a drivers license exam program using methods [closed]

I am trying to write a program that grades the written portion of a driver's license exam where the user needs to answer 15 out of 20 question correctly to pass. There should be a method that will ...
5
votes
4answers
66 views

Should we create named string constants in Java when the usage is obvious (reading of named settings from the XML))?

Usually it is a good style in Java to create named constant for string (and other) hardcoded values. Using the example below I want to know how pedantic should I be in it. I use java class as a ...
2
votes
2answers
63 views

My first ASF Maven commit — don't understand the maintainer [closed]

I created my first commit for ASF Maven today. In the PR I was asked two things. By the way: "understand" doesn't mean I speak another language. It is more about his and my opinions and arguments. ...
4
votes
2answers
61 views

Human Jug and Glass

I am a beginner in Java. I have created this small project in Java with the inheritance concept. Here the Human will fill, pour and drink water. There are three classes: Glass, Jug and Human. Let me ...
0
votes
1answer
28 views

how can i get compound word's list in suggestions using jazz spell check with java

This little program was written for an assignment in a data structures and algorithms class. I'll just note the basic requirements: Given an inputted string along with mode(0=spell check , 1=...
2
votes
2answers
51 views

Bubble Sort with tests

I've become a bit rusty in Java. This is an attempt at brushing up my skills. Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the ...
5
votes
1answer
66 views

Calculating the average of all nodes in a Binary Search Tree using visitors

I'm required to calculate the average value of all nodes in a BST using a Visitor, I'm not sure if I did this correctly or if i could just calculate the average ...
3
votes
2answers
437 views

Caesar-Cipher - 2nd follow-up

I've now used the tips, you can find here and there, to improve my code: ...
3
votes
1answer
42 views

Multiple buttons and their event handlers in JavaFX

In my project I used this code to create a GUI using JavaFX. The aim was to have a screen with 7 buttons on it. Next, depending on which button is pressed another set of buttons will appear on the ...
0
votes
1answer
55 views

Cryptopals first challenge - hexadecimal to base64

I've just started the cryptopals-challenge, and now wanted to show my solution to the first challenge here: ...
2
votes
1answer
44 views

Priority queue with Max-Heap

I'm studying with book "Introduction to Algorithms" and implemented PriorityQueue without existed Class. I made a MaxHeap class with Array and made a PriorityQueue with my Heap class. Actually code ...
1
vote
2answers
19 views

how to allow user to input results in Array using java?

I want to allow the user to enter a number of race results (A minimum of 2 participants and a maximum of 7) I feel that I could use a much shorter code, (I am a beginner of Java only 2 months so any ...
5
votes
2answers
113 views

Custom Ranking algorithm

Could you review the approach and let me know if there is a better way to implement the same using different java techniques (also performant)? Requirement as follows: The products that are ...
4
votes
2answers
70 views

Fleissner-Grille / Turning-Grille in Java

I've implemented the cryptographic method of the Fleissner-grille aka Turning-grille . Here's the code: ...
3
votes
0answers
37 views

java swing super simple calculator mvc

i am trying to learn mvc (model view controller). there are many texts out there explaining what mvc is. but not many explaining how to actually code mvc. i found a bunch of questions here asking ...
-2
votes
0answers
26 views

Arrays of References: Add Song [closed]

So we have a playlist of Song objects and one of the methods needed is an addSong method. We need to first check if there is enough space in the array of references. If it isn't, we need to create a ...
3
votes
1answer
75 views

follow-up - caesar-cipher - java

I now processed the suggestions you can find here. I've deleted some duplications and corrected some other minor mistakes. Here's the code: ...
8
votes
2answers
399 views

Java implementation of the caesar-cipher

I've wrote a little program that encrypts text by using the caesar-cipher. Also it contains a little GUI, created by using swing. Here's the full code: ...
-3
votes
0answers
19 views

Failure to check if user guess is a hit or miss in Java Battleship [closed]

Okay, So I'm creating a basic battleship game in Java, where the ships are auto generated on a grid, and the players enter both a column, and a row. If the column and row equal the same column and row ...
3
votes
3answers
66 views

Balance Parenthesis

The function should return a string with balanced parenthesis. The code I wrote is working for all the inputs below. I am using stack data structure. I suppose this should work for all the edge cases. ...
-2
votes
0answers
31 views

Producer-consumer problem - both end up waiting [closed]

new to multithreading. I wrote this program which should be a solution to the producer-consumer problem. The problem is that both a producer and a consumer end up in the waiting state. What seems to ...
-3
votes
0answers
35 views

Sort a String ArrayList that contains numbers [closed]

I have a little problem, I wouldn't know how to sort a String list. I don't want to sort it alphabetically, I want to sort it from highest to lowest or from lowest to highest. ...
5
votes
4answers
210 views

Program in JAVA to generate random alphanumeric string

This code will generate a pseudorandom alphanumeric string of given length. I would welcome suggestions on how to make it more random. Beyond that, have I made any convention violations, Exception ...
0
votes
1answer
57 views

Implementation of Conway's Game Of Life on Android

I ended up using 2x 2D arrays with a one element border around everything to simplify the kernel logic. ...
3
votes
1answer
83 views

Finding shortest path in matrix

Given an N x N matrix of positive integers, I need to find the shortest path from the first cell of matrix to the last cell of matrix. I can move exactly x steps from any cell, where x is the value of ...
2
votes
4answers
161 views

“Rock Paper Scissors Game” Java

What can make this code better? And how could I improve this code? Oh and what I would love is if someone has a project that is not that challenging but I could learn a lot from it :)   ...
0
votes
0answers
51 views

Java Neural Network Implementation

I have recently tried to get a better grip on machine learning from a point of implementation - not statistics. I've read several explanations of an implementation of a Neural Network via pseudocode ...
6
votes
2answers
66 views

Opposite access to enums

Consider I have many enums (Java) that looks somewhat like this: ...
4
votes
2answers
165 views

Mars Rover technical Challenge in OOP

I am trying to practice OOP and TDD concepts, I have written this code for Mars rover challenge from marsrovertechchallenge . Can you please review my code from my GitHub repository? Or you can ...
3
votes
0answers
39 views

Controller class for an input dialog

I am learning OOP, concretely Java, by developing a real life business application for aimed for repair shops. I have followed MVC pattern design for GUI elements of my application. I was wondering do ...
4
votes
5answers
192 views

Counting number of `1` digits in the value of \$11^n\$

I am trying to improve the efficiency of my code, The Question is: Given a value n, where n is in the range ...
2
votes
1answer
95 views

Converting HashMap data to a Response object

I have a HashMap and I want to convert data in it to a Response object. Is it possible to achieve this code that parses the string in a better and optimized and cleaner way, maybe by using streams? <...
0
votes
0answers
23 views

Playframework Java application with Couchbase database, retrieve and lock the document while saving

I am retrieving a document(UserDetails) from Couch with a lock of 5 sec, than updating the document and saving it. Code is ...
1
vote
0answers
20 views

How to quickly work a linechart created with jfreechart

Currently I use jfreechart through swt. The current problem is tens of thousands of files (currently between 10,000 and 20,000, up to 100,000 later) I currently use ...
6
votes
3answers
129 views

find all anagrams of a given word

I wrote this program which generates anagrams for a given word. The init function will create a dictionary of words. it can be read from a text file or array. Here I'm reading words from an array to ...
5
votes
2answers
249 views

A type of game simulation dropping disks

Quincunx is that little game where you drop a ball or disk down rows of nails in a pyramid formation until they land in a slot. This was a project for my class, but it's already been submitted. I am ...
0
votes
0answers
64 views

Add two inputs in base and return result in array [closed]

The input of the method is two inputs in base: each input is given as array of its digits in that base. The method should add the inputs and put the result in outDigits (if there is an overflow,...
3
votes
1answer
43 views

Easier way to find matching array from a lot of arrays

I have the following arrays which save the MAC-adresses of a lot of bluetooth beacons and their positions in a building: ...
5
votes
1answer
93 views
3
votes
0answers
41 views

Playframework Java application, saving user details into Couchbase database

I am creating back-end for a web-application in Play framework with Java, using Couchbase for storage. This class is saving and fetching User details from Couchbase....
3
votes
2answers
90 views

Adding/removing songs to a playlist

This is a simple Java application, which adds songs to a playlist, removes songs from playlist based on indexes. A database is not used in this. I am creating dummy data through a ...
1
vote
2answers
141 views

Create secret messages

The problem is stated in Encrypt this!: Your message is a string containing space separated words. You need to encrypt each word in the message using the following rules: The first letter ...
2
votes
1answer
83 views

Bingo Game that needs someone to look over because of repetitive coding

I am a beginner Java programmer and am in need of someone to read over it and help me condense my repetitive coding. I wrote code for a Bingo game and feel like I repeat code too often. If anyone ...
7
votes
1answer
113 views

Gem Puzzle game

I started learning JavaFX a few days ago and I have just created as an exercise a simple Gem Puzzle game. The puzzle pieces can be moved if we click on them. The visual aspect of the game is very ...