Category "java"

Leetcode Q9 Palindrome Number same code works in Java but not in C++

I tried solving this problem: https://leetcode.com/problems/palindrome-number/ using code: class Solution { public: bool isPalindrome(int x) { int r

finding the longest sequence of identical digits in an integer (Java)

I need to write a recursive method that takes an int as input and returns the longest sequence of identical numbers in it as an int (NOT as a string). counting

PDF from HTML with only alphabetic (Latin) using itextpdf

I believe that the answer to my question is very easy for those who have had experience with this, and I thank you in advance. Namely, I managed to export a PDF

Spring OAuth2 name always null

New to OAuth2 and Spring framework. Have followed two introduction guides to it so far (for example this one) and the OAuth2User object (org.springframework.sec

auto.register.schemas set to false doesn't work as intended

auto.register.schemas=false doesn't work as I expect. If I read the documentation it's suppose to counter the producer to regsiter new schemas. https://docs.c

How to call the system menu as in the Chrome browser to set the default browser

I have a Browser app, I need to set it as my default browser. I want to call such a system menu (as in the photo) only instead of Chrome - the name of my applic

How to sort by two fields in Java?

I have array of objects person (int age; String name;). How can I sort this array alphabetically by name and then by age? Which algorithm would you use for th

How to sort by two fields in Java?

I have array of objects person (int age; String name;). How can I sort this array alphabetically by name and then by age? Which algorithm would you use for th

Axon Framework: Aggregate Autowired Bean throws NullPointerException in Test

Springboot and Axon: Basically I am unit testing an aggregate that uses three different ObjectMapper instances, each with a different configuration. These are d

How do I take the users input and have the program loop that many times for a for loop? [closed]

How do I take the user's input for how many legs are on the trip and have it loop that amount of times? int counter = 0; int gas = 0

Java For Loop Repeating Sequence Triangle Program

Can someone help me write the program in Java that prints the following triangle? I'm having trouble coming up with a solution. Example User input: Enter increm

Using nested Quarkus tests with different test profiles

I want to create a test case for a class Foo. That class Foo gets an instance of Bar injected; however, there are different implementations of Bar, and the deci

No context error in Java, but the context is set immediately after window creation [closed]

I'm trying to make a game using LWJGL 3, but I get this error: No context is current or a function that is not available in the current contex

Dynamic JFreeChart for custom X-Axis values

I make a JFreeChart for displaying values from serial port. It is working well, but I want to make X-axis movable from right to left. It means when plotting the

Is there an expiring map in Java that expires elements after a period of time since *first* insertion?

I tried looking at cache mechanisms, such as Guava's Cache. Their expiration is only since last update. What I'm looking for is a data structure that stores ke

How to split a readLine but dont split values inside apostrophes?

Example txt file ADD 'Cordless Screwdriver' 30 1 2 COST 'Multi Bit Ratcheting' FIND 'Thermostat' FIND 'Hand Truck' SELL 'Hammer' 1 QUANTITY 'Paint Can' FIRE 'Jo

How do I capture the time a tcp socket is moving from ESTABLISHED TO WAIT state

I have a Java WebSocket server that uses Netty to establish WebSocket connections. This is basically a chat application where a few agents will be interacting w

Best way to convert a List<Object> to List<Object.Property>

Consider the following use case: I have List<Song> which holds an ArrayList. I want to translate the above on-the-fly to List<String> which may be a

Parentheses around data type?

I am a beginning programmer and came across this in my textbook: public boolean equals(DataElement otherElement) { IntElement temp = (IntElement) otherElem

Searching data in the JTable using

I have a table that I post with a database connection. I am searching the table, but after searching, selecting the row and bringing the result to the textbox r