The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
vote
1answer
52 views

Remove Duplicates From Linked List In Place - Java [closed]

This is my implementation ...
0
votes
1answer
103 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
75 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 ...
1
vote
2answers
59 views

Filter for logging http request parameters

I have written a filter that intercepts http calls and logs request parameters. ...
2
votes
1answer
47 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
34 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
117 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 ...
1
vote
0answers
77 views

Building maps for Dgraph integration tests in Java 8

I want to refactor this in Java to reduce my code duplication. ...
0
votes
0answers
22 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
86 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
182 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
54 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
236 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 ...
2
votes
1answer
114 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
105 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
77 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
85 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
234 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
140 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
59 views
2
votes
2answers
197 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
121 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
57 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
71 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
68 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
173 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
78 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
61 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 ...
6
votes
4answers
537 views

Counting multiples of 3 up to a given number

I'm attempting a practice problem in Codeforces that requires you to find the number of multiples of 3 less than or equal to a given number. I have written the following code but it gives a TLE once ...
3
votes
2answers
139 views

Finding unpaired number in an odd Array of integers

A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except ...
3
votes
1answer
305 views

Object-oriented calculator

I have solved an assignment (Exercise 3) from the MOOC Object-Oriented programming with Java, part II, but I'm not enrolled in said course. Assignment Summary: Make a simple calculator. You ...
2
votes
1answer
50 views

Java file transfer through sockets

I am making a program that transfers files from one client to another. Right now I am just working on sending the file to the server and then later I will work on transferring it to the other client. ...
3
votes
1answer
115 views

JAVA Shopping Cart Design

Recently, I have appeared for coding exercise to design the Shopping Cart which should have following features: handles barcoded (like Chips) and non-barcoded item (like Banana 400gm) Can add item, ...
1
vote
1answer
81 views

Bowling Kata in Java

I am sharing my Bowling Game Score Kata made in Java, it is available for whoever wants to code review it. I appreciate any comments. ...
7
votes
5answers
1k views

Finding all possible pairs of square numbers in an array

I am writing a program that allows me to find all possible pairs of square numbers including duplicates. We can also assume the array elements to be of positive integers only. e.g an array of {5,25,3,...
1
vote
0answers
57 views

Making text based Blackjack game in Java. Can't figure out how to deal with Ace(1/11) and Splitting [closed]

I've been learning java for about a year in University and decided to start this Blackjack game which I can hopefully animate into a full app in the future, although I'm still working on the ...
2
votes
1answer
89 views

Create Node tree from list of paths

I have this list of paths: ...
3
votes
1answer
54 views

Pycharm plugin for imports cleaning

I have written Pycharm plugin for integrating pycharm with tidyimports. I have followed steps mentioned in Simple Pycharm Plugin Example. Below is the code that I have written, it works but I need ...
4
votes
1answer
93 views

Random password generator (Java)

I wrote this program recently to generate random passwords for myself. It works well but it's been a long time since I wrote any java and am just looking on ways to clean up the code. I'm also not ...
2
votes
1answer
43 views

Finding the number of times the code will generate an alert depending upon whether the transaction is fraudulent

Please refer to this problem from Hackerrank HackerLand National Bank has a simple policy for warning clients about possible fraudulent account activity. If the amount spent by a client on a ...
3
votes
4answers
97 views

Java program to manage animal data and store them in text files

I made this program as a baby step to creating an animal shelter management system that will be used in a real life animal shelter. The goal is to move from text files to an online database, and from ...
2
votes
1answer
66 views

Java Perlin noise implementation

I've decided to code Perlin noise generator in Java. It works pretty well, I just want to know If I am doing everything right and if it is a valid implementation! PS : The ...
2
votes
1answer
66 views

Remediation for security vulnerability due to storing sensitive information in strings

Security assessment of our codebase reported the following vulnerability - Vulnerability Description The method x() in xyz.java stores sensitive data in a String object, making it ...
5
votes
2answers
138 views

Java program to detect the Java class File Format magic number, in a given file

Description: I wrote a Java program that checks whether the content of the given file begins with the Java class File Format magic number 0xCAFEBABE, in big-endian ...
2
votes
1answer
60 views

Find the number of all specific substrings in a string

I would like to ask a code review regarding a concrete exercise. Let's suppose I have to get the number of all specific substrings in a string. We call something specific if any of these conditions ...
0
votes
1answer
75 views

One try with multiple catch blocks vs nested try

I am creating program which will parse .csv file and I am using FileReader and Scanner classes from java API. ...
-2
votes
1answer
57 views

Bodyless Self-Closing *for* Loop [closed]

I use self-closing bodyless for loop to quickly find an element within an array or collection. Learned it from a Java teacher. But I'm seeing warnings on certain IDEs that have a code inspection tool. ...
2
votes
2answers
106 views

Simple subnet calculator and parser

I have started to learn Java for the past 20 days with no prior coding/comp science experience. My brother gave me an idea to make a subnet calc/ping tool to enhance my knowledge and mentored through ...
1
vote
1answer
147 views

HackerRank Code “Determining DNA Health”

I am working on this problem: https://www.hackerrank.com/challenges/determining-dna-health/problem passing some test cases and time-out on others (no wrong answers). The code is here: ...