Java Console Input and Output: System.out, Console and IO
Java console input and output with System.out, System.err, printf, Scanner, Java 25 IO, the Console class, hidden passwords and the null console case.
Java console input and output with System.out, System.err, printf, Scanner, Java 25 IO, the Console class, hidden passwords and the null console case.
Calculate the average of N numbers in Java from user input, arrays and lists, and avoid integer division, overflow and empty input bugs.
Count vowels and consonants in Java with a loop, switch, streams and regex, plus y, digits, accents and locale pitfalls, with tested examples.
Reverse words in a string in Java with split() and join, List.reversed(), a loop, streams, two pointers and StringUtils, with extra spaces and punctuation.
Sort a String array alphabetically in Java with Arrays.sort, ignore case, reverse it, use Collator for accents, and handle null elements.
Swap two numbers in Java with a temp variable, arithmetic, XOR or one line, and learn where each trick fails and why a swap method cannot work.
Find prime numbers from 2 to N in Java with the Sieve of Eratosthenes, check one number fast, get the first N primes and test big numbers.
Check a deficient number in Java with a loop or the faster square-root method, compute the deficiency, and classify perfect and abundant numbers.
Check a pronic number in Java with a loop, the square root or the 4x+1 test, handle long values safely, and generate the n(n+1) sequence.
Check a Harshad number in Java with a digit-sum loop that never divides by zero, try other bases, count Harshad numbers and build a lucky-draw rule.
Check a happy number in Java with a HashSet, Floyd cycle detection or the stop-at-4 shortcut, and see why every unhappy number reaches the same cycle.
Check a disarium number in Java with exact integer math, see why 89, 135 and 518 qualify, list all 20 of them and compare them with Armstrong numbers.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.