Java Core & Fundamentals Tutorial
Java tutorial for beginners on Java 25. Install the JDK, run a first program and follow a 12-step learning path plus an index of every Java topic.
Java tutorial for beginners on Java 25. Install the JDK, run a first program and follow a 12-step learning path plus an index of every Java topic.
Fix Error could not find or load main class in Java by reading the Caused by line. Package, classpath, typos, missing JARs, Main-Class and IDE cases.
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 examples grouped by task, from a program to add two integers with overflow checks to number, string, console and JVM behavior programs.
Calculate the average of N numbers in Java from user input, arrays and lists, and avoid integer division, overflow and empty input bugs.
Set classpath from command line in Java with -cp and CLASSPATH on Windows, Linux and macOS, with wildcards, quoting, argument files and the -jar trap.
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.
Learn to compare float and double in Java with a relative tolerance, Double.compare(), NaN and -0.0 rules, float vs double precision and BigDecimal.
sun.misc.Unsafe explained for Java 25 with what it does, the JEP 471 and 498 deprecation steps, warnings, and how to move to VarHandle and the FFM API.
How the Integer cache in Java works, why 127 == 127 but 128 does not, cache ranges of all wrapper classes, AutoBoxCacheMax and the equals() fix.
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.