Skip to content

Tag: java

Regex to validate that every digit is different from each other

I have to validate strings with specific conditions using a regex statement. The condition is that every digit is different from each other. So, 123 works but not 112 or 131. So, I wrote a statement which filters a string according to the condition and prints true once a string fullfies everything, however it…

Complex logix in Java Comparator

I have a list of actors where each actor has a type (“Artist”, “Producer”, “Mixer”…some other types). I need to order this list taking the following into consideration: Actors with the type of “Artist” will be displayed first. Actors with the type of “Producer” will b…

how do I make while loop run until a certain input is placed?

the idea is basically the loop takes in input and it runs until I type “quit” but it doesn’t work the way I want to and I can’t figure out why 🙁 (p.s. im a beginner that came from python pls be kind) I also tried adding a temporary variable so that the while loop could check the condit…

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…