Skip to content
Advertisement

Tag: loops

How can I shorten many while loops?

This is one of my first attempts to use Java and I tried my best, but I need to shorten it so it’s not so long. Important is that it keeps all the coins of the Euro. It’s a German code so geld means money. This part of the code System.out.println(rgeldt + ” mal 2 Euro”); just means how often

Regex for letters and numbers with any underscores in between

I’m trying to create a Regex String with the following rules The username is between 4 and 25 characters. It must start with a letter. It can only contain letters, numbers, and the underscore character. It cannot end with an underscore character. when it meets this criterion I want the output to be true otherwise false, but I only get

Reading a file and saving each line into a variable

For a project of mine, I’m trying to read a file of Integers and save each line into a file. Each of the files I’m reading have a different amount of lines. The file would look like 17 72 61 11 63 95 100 Is there a way I can use a loop and save the value in a different

Retrieve all queue data in for loop

I have the following code which works fine but I am struggling to figure out how to retrieve the last value in the queue. Here is the output: Answer Since you’re incrementing x and decreasing the size of the queue, x will eventually become bigger than the remaining queue size before the queue is empty. You can change your loop

Advertisement