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
0
votes
0answers
4 views

Extract a files in directory from war archive using ansible unarchive

I'd like to extract two files in directory from war. the two files )application.properties and logback.xml) are exists in this path /WEB-INF/classes/ For ansible I've tried: ...
6
votes
2answers
492 views

Chaos with Newton’s method

The following is the program 3.2.6. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: ...
-1
votes
0answers
34 views

Producer/Consumer classic problem - Synchronization [closed]

The following code is a simple producer-consumer problem. It works as intended. However, In the process of debugging, I realized that if in the Consumer class, I move the synchronized block to the ...
0
votes
0answers
25 views

Simplifying code block [closed]

What's the most simplified (shortest form) way to write this code block: ...
-1
votes
0answers
30 views

Resizing a hashtable map [closed]

I am trying to get my resize() to work. I am using an AutoGrader and it keeps saying I have a NullPointerException and I can't figure out why. public void resize() { ...
3
votes
2answers
84 views

A simple Snakes and Ladders implementation in Java

I created a pretty straight forward snakes and ladders implementation in Java just for the heck of it. The program can be summed up as- Object of Board contains an array of Type Tile to represent the ...
3
votes
1answer
47 views

Simple Pizza Ordering Application in Java

I was inspired by a previous post here that also wrote a pizza ordering application. This is the attempt I have made using OOP in mind as I thought that would be just the way to go. Here is Pizza.java ...
3
votes
1answer
40 views

Precise timing event dispatching in Java

I have coded a tool to produce precise timing events in Java. You set a value in BPM, and you receive events in your listener at the most precise timing it possibly can be with Java. It is basic. A ...
3
votes
1answer
46 views

Java Singly-linked List: how to be efficient and clean

this is my first time on StackExchange. I am new to writing code. This is a singly-linked list I made in Java using generics with no sentinel nodes (i.e. no empty head and tail nodes). Looking for ...
5
votes
2answers
273 views

Exercise for ordering pizzas with user input

I've only been learning Java for two weeks, and I had to complete this task as part of my course. My instructor could not give specific feedback as answer file is already provided, the code works but ...
2
votes
0answers
34 views

Bounded tasks with completion service

I have the following implementation which does the following There are incoming download tasks and downloads need to be done concurrently. Each download task has its own following task and when a ...
3
votes
1answer
33 views

Displaying some multiples

Displaying Some Multiples Write a program to calculate the multiples of a given number. Have the user enter a number, and then use a for loop to display all the multiples of that number from 1 to 12. ...
1
vote
1answer
97 views

Drawing dragon curves using Turtle graphics

This is exercise 3.2.23. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a recursive Turtle client that draws dragon fractal. The following is the data-...
5
votes
2answers
448 views

Electric potential visualization

This is exercise 3.2.23. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a program that creates an array of charged particles from values given on ...
4
votes
1answer
61 views

Export Hero information and list of his items to excel sheet/csv

I created simple export tool for my project. My requirments was to create one csv file for details of my hero which contains name, level, gold etc. And second file for list of items. Both of files ...
2
votes
1answer
47 views

Data-type implementation for multiple dynamic histograms

This is almost exercise 3.2.14. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne (since I am self-studying, I changed it a little bit): Develop a version of ...
4
votes
1answer
132 views
+50

Mancala Iterative Deepening

This is my iterative deepening alpha beta minimax algorithm for a two player game called Mancala, see rules The game and corresponding classes (GameState etc) are provided by another source. I provide ...
2
votes
1answer
47 views

Converting an integer to a hexadecimal string representation in Java

I have rolled my own Java method for converting ints to the hexadecimal Strings: ...
-3
votes
0answers
24 views

When the button is clicked it returns a message or displays it. Spring Boot [closed]

I'm fairly new spring boot and really trying to learn as much as possible. Currently, I'm creating simple vending machine web application. I was able to display the button but don't know how to write ...
1
vote
1answer
42 views

Simplifying data-type implementation for axis-aligned rectangles using data-type implementation for closed intervals

This is exercise 3.2.8. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a data type Interval that implements the ...
4
votes
3answers
158 views

Many DB queries and conditions [closed]

I don't know it is some design pattern for it or I can't do it in a different way the code looks like this: ...
6
votes
3answers
146 views

Data-type implementation for rational numbers

This is exercise 3.2.7. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Implement a data type for rational numbers that supports addition, subtraction, ...
8
votes
1answer
138 views

Data-type implementation for axis-aligned rectangles

This is exercise 3.2.1. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Consider the following data-type implementation for axis-aligned rectangles, which ...
4
votes
0answers
37 views

Java blocking queue download process scenario

I have the following scenario . I have incoming file download requests and each download is happening in different thread until pool size is exceeded. And after a download completed, a processor ...
2
votes
1answer
62 views

Defining a finite set of instances of a class to check against [closed]

I have a Type class that will have many instances. I get the instances from a web service. The Type class has a ...
8
votes
2answers
913 views

Swapping bytes of an integer in Java

I have this tiny function that expects an int and returns an int with the bytes swapped: ...
4
votes
1answer
93 views

Find first index of 1

Given a sorted array consisting 0’s and 1’s. The task is to find the index of first ‘1’ in the given array. I submitted the below code in geeks for geeks and the execution time is 5.77. Need help in ...
3
votes
2answers
70 views

Binary to decimal

Can I make this code somehow faster and is this readable? I'm a beginner and in later I'll make another class with Decimal to Binary conversion, but first I've to know how to do that. ...
4
votes
1answer
67 views

Java 2 grouped thread scenario

I have the following multi thread scenario and the codes. It looks kind of messy and want to know if I can make it better or if there is any flaw to fix. When a request arrives, one thread downloads ...
10
votes
1answer
156 views

Generating colorful Mandelbrot and Mandelbar set wallpapers

The following is the program 3.2.6. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: ...
1
vote
0answers
45 views

Is volatile enough in this case?

Below is my app's start/stop procedure, start/stop code is handled by a single-threaded ThreadPoolExecutor, so I'm guaranteed there's only one thread can be active ...
0
votes
2answers
70 views

Better way to write this program in java?

I am new to writing java code and I would like to improve my skills. I would like someone to review and critic me on where I can improve on. Here is a small program I wrote in java about matrices and ...
2
votes
2answers
84 views

Loan application service based on user credit score

The following microservice is just handling loan application and response the result of the application is accepted or rejected. It is part of my assignment for an interview. The project description ...
6
votes
2answers
123 views

Implementation of oil-painting filter for images

This is web exercise 3.1.14. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Set pixel (i, j) to the color of the most frequent value among pixels with ...
6
votes
3answers
150 views

CSV to HTML Converter

I have written a little program that converts a CSV-File to an HTML-Table. It works for my purposes. But are there parts in my code that can be written more clean? Can you improve maybe the ...
5
votes
1answer
135 views

Drawing a Thue-Morse pattern recursively

This is web exercise 3.1.63. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a program that reads in a command line input N and plots the N-by-N Thue-...
2
votes
2answers
78 views

Different approach Union Find

I am studying algorithms and I did this "Union Find Like" algorithm. I have one array of objects with a reference and I make the union pointing to the same reference instead of have two int[]...
2
votes
2answers
53 views

Treating Optional values

I have a situation when there could be and could not be values in database, which is why i return optional, so the response object that goes back to the UI could be different depending on the ...
6
votes
2answers
490 views

Implementing a word-chain checker

This is web exercise 3.1.45. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a program that reads in a list of words from the command line and prints <...
3
votes
1answer
48 views

Implementation of Scytale cipher (encryption and decryption)

This is web exercise 3.1.41. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: The scytale cipher is one of the first cryptographic devices used for military ...
2
votes
1answer
38 views

Login system using callbacks in android

I wrote a login system for an app I am developing, but I'm not really happy with the code I have at the moment. I feel like there is a better way at tackling a problem like this. In particular I'm not ...
4
votes
1answer
63 views

Implementation of glass filter for images

This is exercise 3.1.39. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a program that takes the name of an image file as a command-line argument and ...
1
vote
1answer
34 views

Repository and service improvements

I have a MongoRepository: ...
4
votes
2answers
100 views

Calculating the Shannon entropy of a string (e.g. E. coli genome)

This is exercise 3.1.34. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: The Shannon entropy measures the information content of an input string and plays a ...
3
votes
2answers
69 views

Encrypts a message using the ADFGVX cipher

This is a Java program I implemented to encrypt a string using the ADVGVX cipher. It takes in the message, the passphrase used to generate the Polybius square, and keyword for the transposition part ...
6
votes
2answers
101 views

Hide certain email characters

Hide email characters: When email only has one letter then just cover that letter with the * symbol e.g. *@gmail.com When ...
1
vote
1answer
29 views

Concise and exception-prone method for running method on component

I have a list of Components. When an actor is connected, I want to run onActorConnected on each component. However, if a ...
3
votes
1answer
63 views

Implementing a Directed and Undirected Graph in Java

I am learning Graphs on my own and want to use a graph for a personal small project, so I decided to take a look here in Code Review for some cool implementations and came across this one by Maksim ...
9
votes
2answers
1k views

Implementation of Kamasutra cipher

This is exercise 3.1.31. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a filter KamasutraCipher that takes two strings as command-line argument (the key ...
1
vote
2answers
73 views

Shortening code for string substitution

I have this short function, it converts a human selected name like "Accelerometer" to "Acc" which a sensor can use: ...

1
2 3 4 5
205