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
4
votes
1answer
33 views

Fast Food Order Simulator

I have been trying learn OOP lately, and have made a simple program that simulates some sort of drive thru experience using a 9 digit keypad to add, delete, and pay for items ordered from the menu. ...
5
votes
4answers
184 views

Java methods to add and authenticate users in MySQL

I'm going through some code and trying to figure out how to get rid of duplicates from the following two methods. Both methods execute a simple login/register query to a local MySQL DB. I couldnt ...
4
votes
2answers
66 views

Find the first missing positive integer in an array of integers

The problem is the one explained in Given an unsorted integer array, find the first missing positive integer Given an unsorted integer array, find the first missing positive integer. For ...
1
vote
1answer
41 views

Reverse chars of each word in a string

An algorithm to reverse characters of each word in a sentence. What would be your concerns regarding the following solution? Example input: "I love New York" output: "I evol weN kroY" ...
1
vote
0answers
27 views

Requesting inputs on improving leetcode's hashset implementation

Leetcode question details.Implented hashset as per leetcode. Looking for critical feedback, improvement suggestions and recommended refactoring. ...
2
votes
0answers
25 views

Banking application for Udemy Java course

I just "finished" a Udemy Java that involves building a banking application. I'm trying to follow the SOLID Principles of Programming while creating new applications. I was hoping to get some feedback ...
2
votes
2answers
64 views

Convert light-years to other representations

the code is very messy, long and I am looking how to shorten it and/or simplify it. There are a lot of repeated variables, for example; 'hourToDay' and then 'hourToDay1', 'hourToDay2' and so forth. ...
2
votes
1answer
44 views

Spring RESTful API handling errors

I made a Spring RESTful api as backend for a website. I would like to get feedback on coverage of errors and the response I return accordingly, am I using the status codes correctly? Basically ...
5
votes
1answer
70 views

Java program to encrypt/decrypt text

I am working on adding a GUI to the project that I was making in some course. I am curious if the layout looks good, if there variables and methods are shared properly between particular classes, if ...
0
votes
2answers
84 views

A java program that gets a key-value pairs from a textfile, which should also print in a matrix/table like [on hold]

I just want to get some advice about code optimization. How can I make this more OOP? How many class should I have for this kind of task? My code already works but I was told to use OOP in a way that ...
-2
votes
0answers
24 views

Back Button not Appearing in the Screen Any idea why? [on hold]

I am a student learning Java. I recently developed a game in Java and now I am trying to develop a Menu for my game. In my Menu, everything is working fine. When I press play, the game starts, and ...
8
votes
1answer
120 views

An array with \$O(\log\ n)\$ time complexity for all operations

Does this exist already? It's an array (=variable-size list with integer indices) where add/remove/set and get all take \$O(\log\ n)\$ time. I couldn't find this anywhere, so I made up the name "Log-...
0
votes
0answers
33 views

Waiting for a list of Future instances to complete [on hold]

There is an ArrayList of Future objects that I need to ensure all complete before I can move on to the next step of an ...
2
votes
2answers
66 views

Server and Client programs for guessing game

I recently had to complete this for a school assignment and I really enjoyed it, but was hoping someone with experience in OO design or maybe just Java in general could have a look and point out ...
19
votes
3answers
3k views

Loading military units into ships optimally, using backtracking

I solved the following problem using backtracking: We are given a list of military units, their weight and their (numerical) strength. We have a number of ships with a limited carrying capacity....
1
vote
2answers
64 views

Reposition vertices at the origin of a coordinate system

This method repositions vertices of an object in such a way that the center of the object is at the origin of the coordinate system. The task is the commented part. While my code does the job I feel ...
1
vote
0answers
24 views

Bookscraper - SpringBoot app

BookstoreScraper is application based on Spring Boot. It allows to scrap data from two biggest polish online bookstores - EMPIK and MERLIN. You can scrap books within 3 options: bestsellers most ...
-2
votes
0answers
15 views

Right way to handle parallel API calls in Java [closed]

I have a web application in Java where as part of client HTTP request handling, I need to make 2 API calls. The way I am planning to implement is to offload 1 API call to thread pool and do the other ...
-2
votes
0answers
24 views

Byte array with max value optimization [closed]

Can somebody help or give some tips,about how can i optimize this code to work faster and still correctly? Tnanks in advance. ...
1
vote
1answer
49 views

Adding a number to an array of digits

I'm a student in my first semester and in my free time and holidays, I do some java training to keep my mind from rusting...so I downloaded this amazing Digital Algorithms practice app and came across ...
1
vote
1answer
42 views

Remove Duplicates From Linked List In Place - Java [on hold]

This is my implementation ...
0
votes
1answer
64 views

Find the product of digits at odd/even places

The 'score' of a race is given. We have to calculate the 'bonus points' to be given to the participant. The '...
3
votes
1answer
48 views

Very simple Hangman game, with a Swing GUI added

I have just started learning basic Java. I would like to know what I can do to improve my coding habits in Java and how to code more efficiently. In this code example, I took code from Very simple ...
-3
votes
0answers
26 views

Java- How to search for a string within a list of objects from user input and retrieve [closed]

It feels like I have read every other question on this page and tried many things but i just don't know why it wont work.... I am trying to search for a serial number(String) of a car through a list ...
1
vote
2answers
54 views

Filter for logging http request parameters

I have written a filter that intercepts http calls and logs request parameters. ...
2
votes
1answer
38 views

Selection Sort Java -Arraylist

I have implemented selection sort in java using arraylist. This selection sort is only for integers . Please have a look and give feedback. can we improve it ? ...
2
votes
0answers
18 views

Updating UI in Retrofit onResponse

I have an Android project that queries the BART train API. I was curious if updating the UI inside the Retrofit onResponse method is correct or if there is a better way. Below is my code. Also, here ...
5
votes
4answers
103 views

Java code to convert between hex & binary strings

I have two methods in my code which are using the majority of the CPU time that convert between binary and hex strings and the reverse. I use a static lookup map to convert the individual characters ...
0
votes
0answers
52 views

Building maps for Dgraph integration tests in Java 8 [closed]

I want to refactor this with functional programming in Java to reduce my duplication. ...
0
votes
0answers
19 views

Process Extension for Oracle Agile Product Lifecycle Management to update product number field with value from the description field

We are digging into a performance issue with our Agile system. This Process Extension (PX) is used to update the product number field with whatever is in the description field. The product number ...
2
votes
1answer
83 views

Java job responsible for processing file statements

I am looking for any refactoring tips to improve code readability. Does it feel like procedural programming? If so, how can I improve it? ...
4
votes
3answers
171 views

Course Statistics Using Arrays and Files

I wanted to get some feedback here on my solution, because the course I am using is not allowing me to submit any answers. Objectives: Write a Java program that: Create a grades.txt ...
2
votes
1answer
52 views

Backbone of bookscraper

DO NOT REVIEW IT. I PROVIDED BIG CHANGES, SO THIS CODE IS NOT UPDATED I'm developing my bookscraper to improve myself in coding and I think I have solid structure that I want to be reviewed by more ...
4
votes
1answer
214 views

The Enigma Machine (CLI) in Java

A few days ago I began to work on my first project that's bigger than any others that I've attempted before. The purpose of this was to learn how to better code using OOP techniques. The code is all ...
3
votes
1answer
106 views

Group a list of strings by length

Is it possible to write this using the stream element? I can get the most of it with stream but it is the add adding string to list which is in the map that I am caught on. ...
2
votes
3answers
94 views

Reading words and counting their occurence in Java

I have very typical problem: Given big text file, containing text. The task is to calculate occurence of each word and print this info from most occured to less. Example input: ...
2
votes
2answers
67 views

Production-ready comparison between byte-array and ByteBuffer

I want to compare the performance difference between using byte[] and ByteBuffer in Java, which approach I should use in my ...
3
votes
1answer
72 views

Ensure difference between sets

An endpoint that my application interacts with allows you to specify which fields are returned in the JSON result. My application will then map the JSON to a POJO using Jackson. Quite often I add more ...
6
votes
2answers
210 views

Object Oriented Ascii dungeon game

I have solved an assignment (Exercise 33) from the MOOC Object-Oriented programming with Java, part II, but I'm not enrolled in said course. Assignment Summary In this exercise, you ...
3
votes
3answers
123 views

A stream version of Fizz Buzz

I'm trying to learn streams and hashmaps, in doing so I want to make a very scalable, very clean version of FizzBuzz while adhering to the book Clean Code by Robert Cecil Martin. ...
-2
votes
1answer
55 views
2
votes
2answers
170 views

Spring service for playing Rock Paper Scissors

I had created a service which does the actual play of Rock Paper Scissors. Below is the service which takes a PlayRequest and updates the State of Player objects given by the PlayerService. So the ...
6
votes
1answer
115 views

Delete all virus-affected files with certain filenames

Purpose of the code is to delete all virus affected files from your pc. ...
1
vote
0answers
43 views

Algorithm X implementation for Minimum Dominating Set

As as final project for a MOOC I wanted to write a program that finds the exact cover set/minimum dominating set from the given social network data. So I did end up with writing this. I kinda followed ...
8
votes
4answers
2k views

Very basic singly linked list

Here is implementation for singly linkedlist. Any suggestions are most welcome ...
6
votes
2answers
58 views

Would log4j be more efficient to utilize than the logger I implemented (Code Below)?

I recently made a logger program implementation in my game engine. Which logs any thing that I send it in either a file or the System.out printstream. I use it like this: ...
2
votes
2answers
59 views

Jsoup connection to URL

I have simple class that I want to ask if is there any possible to improve it? I mean, for me it looks poor. Is there any way to use here try-with-resources, stream or ...
6
votes
3answers
120 views

Evaluating a math expression given in string format

I am currently working on building a calculator using Java and JavaFX to practice my coding skills. I wrote the following methods to evaluate a given expression. What can I improve? Is there ...
6
votes
2answers
72 views

Count all X-shaped bits from 8 integers

I am given 8 positive 32-bit integer numbers. The task is to write program to count all X-bits. X-bits are groups of 9 bits (3 rows x 3 columns) forming the letter "X". task is to count all X-bits ...
2
votes
1answer
53 views

Implementation of Generic Binary Tree Code

I'm in the process of independently learning Generics as a way to build on a college assignment for Binary Search Tree. I've completed this program without Generics first and now I've converted over ...