Article index

Java: Abstract interfaces and abstract interface methods
This article explains the effects of making interfaces and interface methods abstract and the history behind it.
  • java
  • interface
  • abstract
  • jls
Java: Why can I access private fields of other objects?
This article explains why one can access private fields of other objects of the same class.
  • java
  • fields
  • private
  • object
  • other object
Java: Accessing private fields of superclass through reflection
Example: Accessing private fields declared in superclass through reflection
  • java
  • example
  • private
  • access
  • reflection
  • inheritance
  • subclass
  • superclass
Java: Accessing private fields through reflection
Example: Accessing private fields through reflection
  • java
  • example
  • private
  • access
  • reflection
Go: Function literals and closures
How to use anonymous functions (lambdas) and closures in Go.
  • go
  • golang
  • function
  • pointer
  • type
  • literal
  • lambda
  • closure
  • anonymous
Go: Append function explained
How to append elements to a slice in Go.
  • go
  • golang
  • append
  • slice
  • string
  • byte slice
  • slice to slice
  • nil slice
Go: How to log and append text to a file
How to open or create a file for writing and appending to a log file.
  • go
  • golang
  • append
  • file
  • logging
Big O notation explained
How to use asymptotic notation to describe time complexity.
  • asymptotic
  • ordo
  • omega
  • theta
  • notation
  • elementary operations
  • worst-case
  • constant
  • logarithmic
  • linear
  • quadratic
Go: Binary search
How to find an element efficiently in a sorted slice.
  • go
  • golang
  • binary search
  • algorithm
  • function
  • slice
Go: Bitwise operators cheat sheet
A complete list of bitwise operators and functions in Go.
  • go
  • golang
  • bitwise
  • operator
  • function
  • not
  • and
  • or
  • xor
  • bit
  • bit clear
  • shift
  • rotate
  • popcount
Go: Broadcast a message on a channel
How to broadcast a message on a channel in Go.
  • go
  • golang
  • broadcast
  • signal
  • wait
  • channel
  • close
Go: Build, append and concatenate strings efficiently
Build strings efficiently with strings.Builder, bytes.Buffer or with strconv append functions.
  • go
  • golang
  • strings builder
  • build
  • append
  • concatenate
  • string
  • efficiently
Java Keyword: catch
The Java keyword 'catch' is explained. The keyword is used to catch an exception and follows immediately after a try block.
  • java
  • exception
  • keyword
  • catch
Java: Chained Exceptions
Chained exceptions, or wrapped exceptions, are used to indicate that a lower level exception was the cause for a higher level exception.
  • java
  • exception
  • suppressed exception
Go: Channels explained
Channels in a nutshell.
  • go
  • golang
  • channel
Go: How to check if a map is empty
How to check if a map is empty in Go.
  • go
  • golang
  • map
  • empty
Go: Check if a file or directory exists
Check if a file or directory denoted by a path exists in Go.
  • go
  • golang
  • file
  • directory
  • path
  • filepath
Go: Check if a map contains a key
How to check if a map contains a key in Go.
  • go
  • golang
  • map
  • contains
  • key
Checked Exceptions: Good or Bad?
Are checked exceptions a good language feature? Or is it a failed experiment where Java is the first and last language to support it? This article describes the pros and cons and explains why it's often misused and when it's a perfect fit.
  • exception
  • checked exceptions
  • unchecked exceptions
  • throws
  • java
Choosing between Checked and Unchecked Exceptions
When is it appropriate for a method throw an exception? Should it be checked or unchecked? This article answers these questions in depth, provides examples and a quick flowchart for future reference.
  • java
  • checked
  • checked exception
  • unchecked
  • unchecked exception
  • api design
  • checked vs unchecked
Java: Class.this explained
This article explains what Class.this means and when it's useful.
  • java
  • class
  • this
Go: Clear a slice
How to clear a slice in Go.
  • go
  • golang
  • clear
  • slice
  • array
  • nil
  • garbage collection
Go: Close a channel
How to close a channel using the close function in Go.
  • go
  • golang
  • close
  • channel
  • goroutine
Go: Command-line arguments
How to access command-line arguments passed to a Go program.
  • go
  • golang
  • command-line
  • argument
Go: Compare slices (arrays)
How to compare slices (arrays) in Go.
  • go
  • golang
  • compare
  • equal
  • slice
  • array
  • byte
  • deepequal
Go: Compare strings
Determining if strings are equal, not equal and their their alphabetical (lexical) order.
  • go
  • golang
  • compare
  • string
  • order
  • alphabetic
  • lexical
  • equality
  • inequality
  • equal
  • not equal
Go: Concatenate slices
How to concatenate two slices in Go.
  • go
  • golang
  • append
  • concatenate
  • slice
  • array
Go: Constructors
Go uses suitable zero values and factories instead of constructors.
  • go
  • golang
  • constructor
  • initialize
  • struct
  • best practice
  • idiom
  • zero value
  • factory
Go: Convert byte slice (array) to string
How to convert a byte slice to a string in Go.
  • go
  • golang
  • byte
  • slice
  • array
  • string
Java: Convert enum to and from int
How to convert an enum value to and from an int using ordinal and values.
  • enum
  • convertion
  • int
Java: Convert enum to and from string
How to convert an enum value to and from a string using name and valueOf.
  • enum
  • convertion
  • string
Go: Convert int to string
How to convert an int to a string in Go.
  • go
  • golang
  • int
  • string
Go: Convert int64 to string
How to convert an int64 to a decimal or hexadecimal string in Go.
  • go
  • golang
  • int64
  • decimal
  • hexadecimal
  • string
Go: Convert rune slice (array) to string
How to convert a rune slice to a string in Go.
  • go
  • golang
  • rune
  • slice
  • array
  • string
Go: Convert string to byte slice (array)
How to convert a string to a byte slice in Go.
  • go
  • golang
  • byte
  • slice
  • array
  • string
Go: Convert string to int
How to convert a string to an int in Go.
  • go
  • golang
  • int
  • string
Go: Convert string to int64
How to convert a string to an int64 in Go.
  • go
  • golang
  • string
  • int64
Go: Convert string to rune slice (array)
How to convert a string to a rune slice in Go.
  • go
  • golang
  • rune
  • slice
  • array
  • string
Java: Converting a char to an int
This article describes how you convert a char to an int.
  • java
  • character
  • char
  • int
  • convert
Go: Copy function explained
How to copy elements to and from a slice in Go.
  • go
  • golang
  • copy
  • slice
  • string
  • byte slice
  • slice to slice
Go: How to count elements in a map
How to count the number of items in a map (hash table) in Go.
  • go
  • golang
  • map
  • size
  • count
  • elements
Java: Creating a custom event
This article shows how to create and listen to custom events in Java.
  • java
  • example
  • custom event
  • observer pattern
Go: Create a custom error
Example of error handling and how to create custom error types
  • go
  • golang
  • create
  • custom
  • error
  • handling
  • example
Go: Current working directory
How to find the path name for the executable that started the current process.
  • go
  • golang
  • current
  • process
  • executable
  • directory
  • folder
  • path
Java: Custom Exception
This page explains and provides examples for how to implement user defined custom exceptions.
  • java
  • exception
  • custom
  • user defined
  • checked
  • unchecked
Go: Data races explained
A data race is easily introduced by mistake and can lead to situations that are very hard to debug. This article explains how to avoid this headache.
  • go
  • golang
  • data race
  • race condition
  • synchronize
  • lock
  • channel
Go: What's the default value of a struct, string, slice, map etc.?
The default zero values of all types in Go.
  • go
  • golang
  • default value
  • zero value
  • struct
  • string
  • slice
  • map
Go: Define an enumeration (enum) with a string representation
How to declare enums and give them a string representation in Go.
  • go
  • golang
  • enum
  • enumeration
  • iota
Go: Delete an element from a slice
How to remove an element from a slice, with or without preserving the order.
  • go
  • golang
  • slice
  • delete
  • remove
  • element
  • order
  • cost
Go: How to delete a file or directory
Use the os.Remove function to delete a file or a folder.
  • go
  • golang
  • delete
  • remove
  • file
  • folder
  • directory
Go: Detect data races
By starting your Go application with the '-race' option, the Go runtime might be able to detect and inform you about data races.
  • go
  • golang
  • data race
  • detection
Go: Detect deadlock
How to detect and debug deadlocks in Go.
  • go
  • golang
  • deadlock
  • detect
  • debug
Difference between Checked and Unchecked Exceptions
This article explains what the difference between checked and unchecked exceptions are.
  • java
  • exception
  • exceptions
  • checked
  • checked exception
  • unchecked
  • unchecked exception
Java: Difference between a.getClass() and A.class
This article discusses the differences between getting hold of a class object through a.getClass() and A.class.
  • java
  • class
  • runtime
  • compile time
  • class literal
Java: Do interfaces inherit from Object?
This article explains why it's wrong to say that interfaces inherit from Object
  • java
  • inheritance
  • jls
  • object
  • interface
Java: Drawing multiline strings with Graphics
Here's an example showing how to draw multiline strings using Graphics.
  • java
  • graphics
  • string
  • drawString
  • multiline
Dynamic programming vs memoization vs tabulation
This article describes the differences between three algorithmic concepts: dynamic programming, memoization and tabulation.
  • algorithms
  • memoization
  • dynamic programming
  • programming
  • tabulation
Java: What is effectively final?
This article explains what effectively final means.
  • java
  • final
  • effectively final
Go: Efficient parallel computation
How to efficiently schedule parallel computation on separate CPUs in Go.
  • go
  • golang
  • parallel
  • computation
  • scheduling
  • cpu
Java: Ellipsizing strings
This article describes a nice way of ellipsizing strings. It respects word boundries and avoids diving into pixel math and the Swing API.
  • java
  • ellipsizing
  • dot dot dot
Go: The empty interface
The empty interface in Go corresponds to a void pointer in C or an Object reference in Java.
  • go
  • golang
  • interface
  • pointer
  • void
  • generic
  • object
  • reference
Java: Collections.emptyList vs new ArrayList
This article discusses the differences between calling emptyList vs simply creating a new list such as new ArrayList.
  • java
  • collections
  • emptyList
  • ArrayList
Go: How to access environment variables
Use the Setenv, Getenv, Unsetenv and Environ functions to read and write environment variables.
  • go
  • golang
  • environment
  • variable
Go: Errors explained
Errors in Go.
  • go
  • golang
  • error
  • interface
  • nil
Java Exception Types
This article explains the difference between the various exception types offered by the Java API.
  • java
  • exception
  • exceptions
  • type hierarchy
  • exception hierarchy
  • java api exceptions
  • RuntimeException
  • Throwable
  • Exception
  • checked
  • unchecked
  • Error
Java Exceptions: Throw, Try and Catch
This article explains what exceptions are, including related concepts such as throwing, propagating and catching.
  • java
  • control flow
  • exceptional control flow
  • throw
  • catch
  • stack trace
  • error
  • throwable
  • error handling
  • exception handling
  • exception
Java: Executing code in comments?!
This article explains why code which seems to be part of a comment is executed and the reasons behind it.
  • java
  • comments
  • unicode
  • puzzler
  • jls
Java: What does final mean, and are final variables always immutable?
This article explains what it means for a variable to be declared final and how it relates to immutability.
  • java
  • final
  • immutable
Java Keyword: finally
The 'finally' keyword is used to open a block of code that executes after the preceeding try block. A finally block is often used to restore state, for instance by releasing resources aquired in a try block.
  • java
  • exception
  • keyword
  • try
Go: Find the Go build version
Use runtime.Version to find the current Go build version.
  • go
  • golang
  • build
  • version
  • release tag
Go: Find an element in a slice
How to check if a slice contains an element.
  • go
  • golang
  • search
  • find
  • contains
  • slice
  • array
Go: Find the type of an object
How to find type information about an interface variable in Go.
  • go
  • golang
  • type
  • check
  • interface
  • variable
  • object
  • element
  • reflection
Go: Percent sign in fmt format
How to add a percent sign in a fmt format specifier.
  • go
  • golang
  • fmt
  • printf
  • percent sign
Go: String formatting cheat sheet
The most common formatting verbs and flags in package fmt at a glance.
  • go
  • golang
  • fmt
  • printf
  • reference
  • format
  • verb
  • flag
  • width
  • padding
Go: Range loops (for each loops) explained
How to loop over slices, arrays, strings, maps and channels in Go.
  • go
  • golang
  • for each
  • range
  • array
  • slice
  • string
  • map
  • channel
Go: For loops explained
How to create and break out of for loops in Go.
  • go
  • golang
  • for
  • break
  • continue
Go: Format a time or date (parsing a date string)
How to format a date or timestamp in Go.
  • go
  • golang
  • example
  • format
  • parse
  • string
  • time
  • date
  • timestamp
  • layout
Go: Format a string without printing it
How to format a string in Go.
  • go
  • golang
  • format
  • string
Java: Formatting byte size to human readable format
This article explains how to format 1000 to 1 kb, 1000000 to 1 MB etc.
  • java
  • bytesize
  • formatting
  • size prefixes
Go: Formatting byte size to human readable format
How to format 1000 to 1 kB, 1000000 to 1 MB etc. in Go.
  • go
  • golang
  • byte size
  • formatting
  • metric
  • SI
  • IEC
Go: Function types and values
How to use function types and function values in Go.
  • go
  • golang
  • function
  • pointer
  • type
Function Pointers in Java
This article shows what Java has to offer in place of C-style function pointers.
  • java
  • functional interface
  • delegates
  • function pointer
  • lambda
  • call back
Java: Functional Interfaces
Functional interfaces are interfaces with a single abstract method. They are used together with lambda expressions and method references.
  • java
  • functional interface
  • lambda
  • method reference
  • sam
  • default methods
  • @FunctionalInterface
Go: Generate a random number in a given range
Generate a different random number between a and b for each program execution.
  • go
  • golang
  • seed
  • generate
  • random
  • number
  • range
Java: Generating a random char (a-z)
This article shows how to generate a random character, either between 'a' and 'z' or from an arbitrary string of characters.
  • java
  • random
  • generate
  • char
  • character
Go: Generate a random character (rune)
How to generate a random character, either between 'a' and 'z' or from an arbitrary set of Unicode characters.
  • go
  • golang
  • random
  • generate
  • rune
  • character
Java: Generating a random number of a certain length
This article shows how to generate a random number with a specified number of digits.
  • java
  • random
  • generation
  • number
  • length
Go: Generate a random string (password, booking reference, etc)
Generate a plain random string as well as strings with password-like constraints, such as at least 1 special character.
  • go
  • golang
  • generate
  • random
  • string
  • password
  • booking reference
Go: Generate a random UUID (GUID)
How to generate a UUID (GUID) in Go.
  • go
  • golang
  • universally unique identifier
  • UUID
  • GUID
Java: Generating a random String (password, booking reference, etc)
This article describes how to generate a plain alpha numeric random String as well as strings with password like constraints, such as at least 1 special character etc.
  • java
  • random
  • generation
  • string
  • password
  • booking reference
Generating competition rankings
This article describes how to generate standard competition rankings ("1224") and all other variants.
  • algorithm
  • generate
  • compute
  • competition ranking
  • standard competition ranking
  • ordinal ranking
  • fractional ranking
  • 1224
  • 1334
Go: Getting started
How to write 'Hello world' and get started with Go programming.
  • go
  • golang
  • hello world
  • basics
  • tutorial
  • tools
Go: Make a goroutine block or sleep forever
How to make a goroutine block or sleep forever in Go.
  • go
  • golang
  • goroutine
  • block
  • sleep
  • forever
Goroutines explained
An introduction to the basics of goroutines.
  • go
  • golang
  • goroutine
  • introduction
Go gotcha: Why can't I add an element to my map?
You can't assign an entry to a nil map in Go.
  • go
  • golang
  • assign
  • map
  • entry
  • nil
  • make
Go gotcha: Can't change entries in range loop
The range loop uses a local variable to store iteration values.
  • go
  • golang
  • change value
  • range
  • iteration
  • loop
Go gotcha: Iteration variables and closures
A data race occurs when two goroutines access the same variable concurrently and at least one of the accesses is a write.
  • go
  • golang
  • closure
  • data race
Go gotcha: Why doesn't this function change my array?
Arrays in Go are values: when you pass an array to a function it gets a copy of the original array data.
  • go
  • golang
  • array
  • slice
  • argument
Go gotcha: Why doesn't increment (++) and decrement (--) work?
In Go increment and decrement are statements written with postfix notation.
  • go
  • golang
  • increment
  • decrement
  • statement
  • postfix
Go gotcha: Why is this index out of range?
Arrays, slices and strings are indexed starting from zero.
  • go
  • golang
  • array
  • slice
  • string
  • index
  • loop
Go gotcha: Why is my JSON output empty?
Only the the exported fields of a Go struct will be present in the JSON output.
  • go
  • golang
  • JSON
  • struct
  • empty
  • marshal
  • encode
  • file
Go gotcha: Extra comma in slice literal
In a multi-line slice, array or map literal, every line must end with a comma.
  • go
  • golang
  • missing comma
  • slice
  • array
  • map
  • literal
Go gotcha: Why can't I multiply a time.Duration with an integer?
There is no mixing of numeric types in Go.
  • go
  • golang
  • integer
  • type
Go gotcha: What's a nil pointer dereference?
You can't follow the nil pointer.
  • go
  • golang
  • nil
  • pointer
  • dereference
Go gotcha: Two variables with the same name?
An identifier declared in a block may be redeclared in an inner block.
  • go
  • golang
  • variable
  • shadowing
  • block
Go gotcha: Why can't I update my string?
Go strings are read-only byte slices (with a few extra properties).
  • go
  • golang
  • string
  • immutable
  • byte slice
Go gotcha: Unexpected values in range loop
The range loop generates two values: first the index, then the data.
  • go
  • golang
  • range
  • loop
  • iteration
  • index
  • value
Go gotcha: Why is nil not equal to nil?
An interface value is nil only if the dynamic value and dynamic type are both nil.
  • go
  • golang
  • nil
  • error
  • interface
  • equal
Java: Handling InterruptedException
This article discusses how to handle InterruptedExceptions. When it should be caught and when it should be propagated.
  • java
  • InterruptedException
  • threads
  • multithreading
Java: How does the assert keyword work?
This article describes how the assert keyword works.
  • java
  • assert
  • semantics
  • jls
Go: How to sort in Go
Custom sorting in Go.
  • go
  • golang
  • sort
  • algorithm
  • function
  • stable
  • slice
  • custom type
Go: HTTP server example
How to write a small HTTP web server in Go.
  • go
  • golang
  • http
  • server
  • example
  • web
  • request
  • get
  • client
  • response
Go: How to implement a FIFO queue
How to implement a FIFO queue in Go.
  • go
  • golang
  • queue
  • FIFO
  • implementation
Go: How to implement a stack (LIFO)
How to implement a stack or LIFO queue in Go.
  • go
  • golang
  • stack
  • LIFO
  • implementation
Java2D: Increasing line width
This article describes how to increase the line width when drawing with a Graphics2D object
  • java
  • graphics
  • graphics2d
  • line width
  • stroke
Go: Inheritance and object-oriented programming
How to get the benefits of inheritance in Go.
  • go
  • golang
  • inheritance
  • object-oriented
  • composition
  • delegation
  • polymorphism
  • dynamic dispatch
  • code reuse
Java: Initialize list with zeroes
This article describes how to initialize a list with zeroes in Java.
  • arraylist
  • list
  • collections
  • initialization
  • zero
  • zeroes
Go: int vs. int64
How to choose between int and int64 in Go.
  • go
  • golang
  • int
  • int64
Java: Why's Double.MIN_VALUE is positive? Integer.MIN_VALUE is negative!
This article discusses the fact that Double.MIN_VALUE is positive, while Integer.MIN_VALUE is negative.
  • java
  • double
  • integer
  • min_value
Go: Convert interface to string
How to get a string representation of an interface value.
  • go
  • golang
  • convert
  • interface
  • string
Go: Interfaces explained
A brief tutorial of Go interfaces.
  • go
  • golang
  • interface
  • empty
  • equal
  • nil
Go: The io.Reader interface explained
How to read byte streams in Go.
  • go
  • golang
  • Reader
  • interface
  • read
  • byte stream
  • buffer
  • scanner
Go: The io.Writer interface explained
How to write byte streams in Go.
  • go
  • golang
  • Writer
  • interface
  • write
  • byte stream
  • writestring
  • optimization
Go: iota
How to generate autoincremented constants in Go.
  • go
  • golang
  • iota
  • example
  • enum
  • start at 1
Java: Is it wrong to use deprecated methods or classes?
This article discusses whether it's right or wrong to use deprecated methods.
  • java
  • deprecated
  • right
  • wrong
Where's the javadoc for values and valueOf methods on enums?!
This article reveals the location of the enum methods values and valueOf.
  • java
  • enum
  • value
  • valueOf
  • javadoc
Go: JSON by example
How to read and write JSON in Go.
  • go
  • golang
  • JSON
  • example
  • file
  • stream
  • enocode
  • decode
  • tag
  • struct
  • map
  • marshal
  • unmarshal
Java: Lambda Cheat Sheet
A cheat sheet (quick reference) of all aspects of lambdas and functional interfaces.
  • java
  • lambda
  • functional interface
Java: <...> (less than/greater than) syntax
The less than/greater than < ... > syntax is called generics. Generics allow you to write a single class or method that handles multiple different types. In other words, you don't need one method for String, one for Integer and so on.
  • generics
  • ArrayList
  • Optional
  • less
  • greater
  • java
Go: Library package example
A template for a small but complete Go library package.
  • go
  • golang
  • library
  • package
  • template
  • example
  • structure
  • readme
  • godoc
  • test
  • licence
  • versioning
Go: Visit all files and folders in a directory tree
Walk the file tree recursively calling a given function for each file or directory in the file tree.
  • go
  • golang
  • file tree
  • file
  • directory
  • recursive
Go: List all files and folders in a directory
Create a sorted list of directory entries.
  • go
  • golang
  • file
  • directory
  • listing
List of Java Exceptions
This page provides a complete list of all exceptions provided by the Java API, grouped by package.
  • java
  • exhaustive list
  • complete list
  • exceptions
  • errors
  • java api
  • java api exceptions
Java: Local methods (or submethods, or inner methods, or nested methods)
This article describes various ways to create methods within methods.
  • java
  • inner methods
  • local methods
  • submethods
  • nested methods
Using C style macros in Java
This article describes how you can use C style macros in Java source files, and why it's (usually) a bad idea.
  • java
  • macros
  • c
Go: Make slices, maps and channels
How to use the make function to create slices, maps and channels in Go.
  • go
  • golang
  • make
  • slice
  • map
  • channel
  • length
  • capacity
  • buffer
  • array
Go: Maps explained
How to use a map (hashmap, hashset) in Go.
  • go
  • golang
  • map
  • hashmap
  • hashset
  • hash table
  • associative array
  • dictionary
  • range
Go: How to compute min and max
How to compute the minimum and maximum of numeric values in Go.
  • go
  • golang
  • min
  • max
  • function
  • integer
  • float
Go: What's the maximum value of an int?
How to compute the max and min values of an int and uint in Go.
  • go
  • golang
  • max
  • min
  • int
  • uint
  • untypes constant
Go: Measure execution time
How to time a piece of code or a function in Go.
  • go
  • golang
  • measure
  • execution
  • time
  • code
  • function
Go: Methods explained
Go methods in a nutshell.
  • go
  • golang
  • method
  • receiver
Go: Multiline strings
How to write a string literal that covers several lines.
  • go
  • golang
  • multiline
  • string
Go: Mutual exclusion locks (mutex) explained
How to synchronize data using a mutex in Go.
  • go
  • golang
  • mutex
  • synchronize
Go: Named return values explained
In Go result parameters may be named and used as regular variables.
  • go
  • golang
  • named return values
  • named result parameters
Java: N-gram generation
This article describes how to produce N-gram sequences from a given string
  • java
  • ngram
  • generation
  • iterator
Go: Empty slice vs. nil slice
A nil slice behaves mostly like an empty slice.
  • go
  • golang
  • slice
  • nil
  • empty
Java: Finding the Nth occurrence of a substring in a String
This article describes how to find the Nth occurrence of a substring in a String
  • java
  • substring
  • character
  • index of
  • indexOf
  • ordinalIndexOf
Java: Find number of regex matches in a String
This article shows how to find the number of regex matches in a string.
  • java
  • regex
  • matches
  • pattern
  • count
Opening a URL in Android's web browser from within application
An example showing how to open a URL in the browser from an Android app
  • android
  • url
  • open
  • browser
  • intent
Go: Opening brace on separate line
In Go an opening brace cannot appear on a line by itself.
  • go
  • golang
  • indentation
  • K&R style
  • Allman style
  • brace
  • gofmt
Go: Operator precedence
Rules for specifying the order in which the operators in a Go expression are evaluated.
  • go
  • golang
  • operator
  • priority
  • precedence
Go: Operators
List of arithmetic, equality, comparison, logical, bitwise and other operators in Go.
  • go
  • golang
  • operators
  • arithmetic
  • equality
  • comparison
  • logical
  • bitwise
  • address
  • pointer indirection
  • receive
5 Java concepts explained: Overloading, overriding, shadowing, hiding, and obscuring
This article describes the differences between 5 different but similar concepts in Java: Overloading, overriding, shadowing, hiding, and obscuring.
  • java
  • overriding
  • overloading
  • obscuring
  • shadowing
  • hiding
  • inheritance
Java: Why you should always override hashCode when overriding equals
This article explains why you should always override hashCode whenever overriding equals (and vice versa).
  • java
  • hashCode
  • equals
  • override
Go: Package initialization and program execution order
A brief description of Go package initialization and program execution order.
  • go
  • golang
  • package
  • initialization
  • init
  • main
  • program
  • execution
  • order
  • cyclic
  • dependencies
Go: Panic explained
Go panics in a nutshell.
  • go
  • golang
  • panic
  • recover
Java: Passing a list as argument to a vararg method
This article describes how to pass a list to a vararg method.
  • java
  • vararg
  • list
  • parameter
Go: Pointer vs. value receiver
How to choose between pointer and value receivers for Go methods.
  • go
  • golang
  • pointer
  • value
  • receiver
  • method
Go: Pointers explained
Go pointers in a nutshell.
  • go
  • golang
  • pointer
  • pointers
  • dereference
  • address
Why large prime numbers are used in hash tables
This article explains why it's common to use large prime numbers when computing hashes for hash tables.
  • hash table
  • prime number
  • prime
  • algorithm
  • hash map
  • hash
Java: Print null
Do you know what happens when you print null in Java?
  • java
  • print
Random Generators: What is a seed?
A seed in a random number generator is the starting point used in the internal sequence of pseudo random numbers. Using the same seed yieds the same numbers.
  • random
  • pseudo random
  • random sequence
  • random generator
Generating a random point within a circle (uniformly)
This article describes how to generate a random point within a circle.
  • circle
  • random
  • radius
  • angle
  • uniformly
Java: Random with a random seed
The java.util.Random no arg constructor uses a random seed which means that each time this constructor is used the random generator is initialized differently.
  • java
  • java.util.Random
  • random generators
  • pseudo random
  • random
  • seed
  • multiple invocations
Go: Read a file line by line
Read a file one line at a time in Go.
  • go
  • golang
  • file
  • read
  • line
Go: Read a whole file into a string (byte slice)
How to read a whole file into a string or byte slice in Go.
  • go
  • golang
  • read
  • file
  • string
Go: Read from stdin
Read a file one line at a time in Go.
  • go
  • golang
  • read
  • stdin
  • standard input
  • line
Java: Reading the Nth line from a file
This article describes how to read a line from a file at a specific line number.
  • java
  • nth line
  • line number
  • file
  • read
Go: Recover from a panic
How to recover from a panic in Go and update the return value.
  • go
  • golang
  • panic
  • recover
  • defer
  • return value
Go: Redeclaring variables
Variables can be redeclared in short multi-variable declarations where at least one new variable is introduced.
  • go
  • golang
  • variable
  • declaration
Go: Regular expressions
How to use regular expressions in Go: examples and cheat sheet.
  • go
  • golang
  • regexp
  • regex
  • example
  • cheat sheet
  • syntax
  • multiline
  • performance
  • match
  • find
  • replace
  • split
Go: Find all substrings matching a regexp
How to find all substrings matching a regular expression in Go.
  • go
  • golang
  • regexp
  • regex
  • example
  • find
  • match
  • substring
Go: Find first substring matching a regexp
How to find the first substring matching a regular expression in Go.
  • go
  • golang
  • regexp
  • regex
  • example
  • find
  • first
  • match
  • substring
Go: Find the location of a regexp substring match
How to find the index of a substring matching a regular expression in Go.
  • go
  • golang
  • regexp
  • regex
  • index
  • location
  • example
  • find
  • match
  • substring
Go: Replace all substrings matching a regexp
How to replace substrings using regular expressions in Go.
  • go
  • golang
  • regexp
  • regex
  • example
  • replace
Go: Split a string using regexp delimiter
How to split a string using regular expressions in Go.
  • go
  • golang
  • regexp
  • regex
  • example
  • split
  • substrings
  • delimiter
Go: Remove duplicate whitespace from a string
How to delete duplicate whitespace from a string in Go.
  • go
  • golang
  • remove
  • delete
  • whitespace
  • string
Java: Removing trailing comma from comma separated string
This example shows how to remove any trailing comma from a comma separated string
  • java
  • comma
  • csv
  • comma separated string
  • trailing comma
  • trim
Java: Removing a range of elements from a list
This article shows an example of how to efficiently remove elements from multiple indexes in an List such as an ArrayList.
  • java
  • range
  • sublist
  • remove
  • clear
  • list
  • ArrayList
Java: Remove duplicate whitespace in strings
How to remove, or collapse, duplicate whitespace in Java strings.
  • java
  • whitespace
  • duplicates
  • string
Java: Removing elements from multiple indexes in a list
This article shows an example of how to efficiently remove elements from multiple indexes in an List such as an ArrayList.
  • java
  • index
  • remove
  • clear
  • list
  • ArrayList
Java: Return Values vs Exceptions
When should a method throw an exception, and when should it use a return value to indicate an error? This article answers the question in detail and provides concrete examples.
  • java
  • exception
  • throw
  • return value
  • error code
  • api design
Go: Reverse a UTF-8 encoded string
How to reverse a UTF-8 encoded string in Go.
  • go
  • golang
  • reverse
  • string
  • UTF-8
Go: What is a rune?
A rune is a Go type meant to represent a Unicode code point.
  • go
  • golang
  • rune
  • character
  • Unicode
  • code point
  • UTF-8
Go: Select explained
How to use the select statement in Go.
  • go
  • golang
  • select
  • default case
  • channel
  • send
  • receive
  • nil channel
Go: Variable declaration outside of function body
Short variable declarations in Go can only be used inside functions.
  • go
  • golang
  • variable
  • declaration
Go: How to get slices of keys and values from a map
How to get slices of keys and values from a map in Go.
  • go
  • golang
  • map
  • slice
  • keys
Go: Slices explained
Usage and internals of Go slices.
  • go
  • golang
  • slice
  • array
  • make
  • append
  • len
  • cap
Sliding Window Algorithm with Example
This article explains the concept of a sliding window when talking about data structures.
  • sliding window
  • algorithm
  • example
  • ngram
Go: How to sort a custom type in Go
Sorting data of a custom type in Go.
  • go
  • golang
  • sort
  • struct
  • field
  • custom
  • user defined
  • slice
  • array
Go: Sort a map by key or value
How to sort a map in Go.
  • go
  • golang
  • sort
  • map
  • key
  • value
Java: How to split a String into an ArrayList
This article shows how to create an ArrayList by splitting a String.
  • java
  • ArrayList
  • split
  • String
  • array
Go: How to split a string into a slice
How to split a string into a slice in Go.
  • go
  • golang
  • split
  • string
  • slice
  • fields
Java Stack Traces: Unknown Source
If a program has been compiled without debug information, you get stack traces like '... at Example.method(Unknown Source) ...'. The only way to get hold of the exact line number is to recompile with debug information.
  • java
  • stack trace
  • debugging
  • unknown source
  • source
  • unknown
Java: Stack Traces
A stack trace describes the state of a thread. It says which methods have been called (but not yet returned) and is often used to debug problems.
  • java
  • stack trace
  • debugging
  • caused by
Go: Stack traces
A stack trace is a list of active method calls at a certain point in time during the execution of a program.
  • go
  • stack trace
  • debugging
Go: String handling cheat sheet
Top Go string functions in a nutshell.
  • go
  • golang
  • strings
  • functions
  • operatations
  • reference
  • concatenation
  • length
  • contains
  • index
  • join
  • replace
  • split
  • trim
  • strip
  • delete
  • remove
  • lowercase
  • uppercase
Go: Structs explained
Go structs in a nutshell.
  • go
  • golang
  • struct
  • field
  • record
Java: Suppressed Exceptions
  • java
  • exception
  • suppressed exception
Go: Table-driven unit testing
How to write a table-driven unit test for binary search in Go.
  • go
  • golang
  • unit
  • test
  • table
  • driven
  • binary
  • search
Go: Create a temporary file or directory
How to create a temporary fila or directory in Go.
  • go
  • golang
  • temporary
  • file
  • directory
Go: Where is the ternary conditional operator?
There is no question mark operator, use the standard if statement instead.
  • go
  • golang
  • ternary
  • question mark
  • operator
  • conditional
  • C
  • Java
Java: Testing array equality
This article explains how to check if two arrays are equal
  • java
  • arrays
  • equality
  • deep equal
  • shallow equal
Java: throw vs throws vs Throwable
This article explains the difference between three similar Java terms: throw, throws and Throwable
  • java
  • exceptions
  • throw
  • throws
  • throwable
Java Keyword: throw
The Java keyword 'throw' is explained. The keyword is used to throw an exception. 'throw' followed by an expression of type Throwable forms a statement.
  • java
  • exception
  • keyword
  • throw
Java Keyword: throws
The Java keyword 'throws' is explained. The keyword is used in method declarations to indicate what exceptions may be thrown by calling the method.
  • java
  • exception
  • exceptions
  • throws
  • keyword
  • checked exceptions
  • method signature
  • method declaration
Time complexity explained
How to estimate the running time of algorithms.
  • time complexity
  • elementary operations
  • worst-case
  • constant
  • linear
  • quadratic
Go: Timer and Ticker explained
How to wait for, repeat and cancel events with a timer or ticker.
  • go
  • golang
  • timer
  • ticker
  • channel
  • wait
  • stop
  • reset
  • timeout
  • interval
  • sleep
Go: How to trim leading and trailing whitespace from a string
How to strip and remove whitespace from a string in Go.
  • go
  • golang
  • trim
  • whitespace
  • leading
  • trailing
  • string
  • slice
Java: try + finally
A finally block follows a try block and is always executed, regardless if the try block finishes normally or exceptionally.
  • java
  • control flow
  • exceptional control flow
  • try
  • finally
Java: try-with-resources
The try-with-resources feature is used to automatically close a file or other resource, no matter the outcome of a previous operation. It's a convenient way of guaranteeing that a state will be restored such as a resource being released.
  • java
  • try
  • close file automatically
  • close stream automatically
  • close socket automatically
  • file
  • try with resource
  • try-with-resource
  • AutoCloseable
Java Keyword: try
The 'try' keyword is used to open a block of code that potentially throw exceptions. A try block is followed by one or more catch blocks to catch any exceptions thrown.
  • java
  • exception
  • keyword
  • try
Go: Type alias
Go type aliases support gradual code repair while moving a type between packages.
  • go
  • golang
  • type
  • alias
  • refactoring
Go: Blank identifier (underscore)
The blank identifier is an anonymous placeholder.
  • go
  • golang
  • underscore
  • blank identifier
  • unused
  • variable
  • import
  • init
Go: Untyped numeric constants with no limits
Numeric constants in Go have no limits and can be untyped.
  • go
  • golang
  • untyped
  • constant
  • const
  • iota
Go: Unused imports
How to avoid the imported and not used compiler error.
  • go
  • golang
  • import
  • used
  • goimports
Go: Unused local variables
How to avoid the declared and not used compiler error.
  • go
  • golang
  • variable
  • declared
  • used
Go: Variadic functions (...T)
A variadic function can be called with multiple arguments.
  • go
  • golang
  • variadic
  • function
  • multiple arguments
  • variable number of arguments
  • slice
Go: Wait for goroutines
How to wait for goroutines to finish with a WaitGroup.
  • go
  • golang
  • wait
  • waitgroup
  • goroutine
Java: What exactly is immutable?
This article pins down precisely what is meant by 'immutable' when talking about Java code.
  • java
  • immutable
What makes a good loop invariant?
This article describes what makes a loop invariant valid and useful.
  • hoare logic
  • loop invariant
Java: When to create a final class
This article explains what it means for a class to be final and why it may be useful.
  • java
  • final
  • class
  • why
  • example
Java: When should I override equals?
This article describes when to override the equals method.
  • java
  • equals
  • override
Where's the javadoc for values and valueOf methods on enums?!
This article explains why values and valueOf methods doesn't have an ordinary javadoc and shows where to find it.
  • java
  • enum
  • value
  • valueOf
  • javadoc
  • jls
Java: Why wait must be called in a synchronized block
This article discusses what would happen if wait could be called outside synchronized blocks.
  • java
  • concurrency
  • wait
  • synchronized
Go: Write a command-line (CLI) application
How to write a command-line (CLI) application in Go.
  • go
  • golang
  • command-line
  • application
  • CLI
  • grep
Java: Wrong results for division?
This article explains why you might get puzzled by result of dividing integers.
  • java
  • integer division
  • division
  • rounding