HomeSearch

Java Pages

Dot Net Perls has example pages for many languages, with explanations and code side by side (for easy understanding).
C#F#GoJavaJavaScriptPythonRubyScalaSwiftVB.NETWPF

ArrayList.

Use the ArrayList from java.util.ArrayList. Add strings and integers to ArrayLists.Java ArrayList Examples

Lambdas.

Use lambda expressions: create Functions, Suppliers and Consumers.Java Lambda Expressions

2D array.

Use 2D arrays and jagged arrays. Initialize arrays and assign elements.Java 2D Array Examples

Array.

Use arrays: create and initialize string and int arrays. Use for to iterate over arrays.Java Array Examples

Boolean.

Use the boolean type and the values true and false. Test them with expressions and ifs.Java Boolean Examples: If True, False

Casts.

Cast variables, including objects and numbers. Arrays too are cast.Java Cast and Convert Types

Character.

Use the Character class to test and transform chars. Call isLetter, isDigit and toLowerCase.Java Character: isLetter, isDigit and toLowerCase

Console.

Use the System.out println and print methods. Read console input with System.in.Java Console Examples: System.out and System.in

Files.

Handle files with BufferedReader and FileReader. Use readLine on text files.Java File: BufferedReader and FileReader

For.

Use the for-loop to iterate over numeric ranges and collections. Compare different loops.Java For Loop Examples

Format.

Use String.format to create strings with variables inserted in them. Handle integers and strings.Java String.format Examples: Numbers and Strings

HashMap.

Use the HashMap class from java.util.HashMap. Perform fast key lookups with hashing.Java HashMap Examples

HashSet.

Use the HashSet type as a set collection. Test for element existence and uniqueness.Java HashSet Examples

If.

Use the if-statement to test a variable. Apply the if-statement, else-if and else.Java if, else if, else Statements

IndexOf.

Use indexOf to search for characters and strings. Call indexOf in while-loops.Java indexOf Examples

Integer, maximum.

Examine the MIN_VALUE and MAX_VALUE final ints on Integer and other classes. Use loop boundaries.Java Integer.MAX VALUE, MIN and SIZE

Keywords.

Learn about keywords in the Java language. Review core parts of Java.Java Keywords

Math.

Use the Math class, part of java.lang.Math. Call Math.floor, ceil and other methods.Java Math Class: java.lang.Math

ParseInt.

Use parseInt to convert strings into ints. Test for valid strings and handle NumberFormatException.Java parseInt: Convert String to Int

Process.

Use ProcessBuilder and Process.start. Issue operating system commands with start.Java Process.start EXE: ProcessBuilder Examples

Random.

Use the Random class and the Math.random method. Generate random numbers.Java Random Number Examples

Regex.

Use Regex: create Pattern and Matcher. Text is tested with regular expressions.Java Regex Examples (Pattern.matches)

Remove duplicates.

Remove duplicates from an ArrayList of strings. Use a HashSet in removeDuplicates.Java Remove Duplicates From ArrayList

Replace.

Use replace, replaceFirst and replaceAll to swap strings, chars and CharSequences.Java Replace Strings: replaceFirst and replaceAll

Return.

Use the return keyword in methods. Return multiple values, return expressions and fix errors.Java Return Examples: Expressions and Void

Sort.

Sort elements in arrays and other collections. Use Arrays.sort and the Comparable interface.Java Sort Examples: Arrays.sort, Comparable

Split.

Separate strings on a delimiter with the split method. Split lines of a file.Java Split Examples

Stream.

Explore the Stream class. Call Arrays.stream and convert an ArrayList to a Stream.Java Stream: Arrays.stream and ArrayList stream

String.

Review the String class. Declare, concatenate and manipulate strings.Java String Class

StringBuilder.

Use the StringBuilder class to append Strings. Benchmark and test StringBuilder.Java StringBuilder Examples

Substring.

Use the substring and subSequence methods. One or two indexes can be specified.Java Substring Examples, subSequence

Switch.

Use switch, and the case, default and break statements, to run code based on a variable.Java Switch Examples: Case and Break

Vector.

Use the Vector type, from java.util.Vector. Vector is a resizable, thread-safe array.Java Vector Examples

While.

Loop with while: this loop helps when proceeding until an unknown end condition is reached.Java While Loop Examples
Home
Dot Net Perls
© 2007-2019 Sam Allen. All rights reserved. Written by Sam Allen, info@dotnetperls.com.