Skip to content

Instantly share code, notes, and snippets.

View harrisonbrock's full-sized avatar
🏠
Working from home

Harrison Brock harrisonbrock

🏠
Working from home
View GitHub Profile
@Test
void stringLengthEqualToZero() {
// Test a string with a length 0.
// Test will return true.
assertEquals(0, "".length());
}
@Test
void stringIsEmpty() {
// Test if a String is Empty.
// Test will return true because the string is empty.
assertTrue("".isEmpty());
}
// Split String By Space Using Limits (return array with three elements)
String[] lines = "The Sky Is Blue".split(" ", 2); // ["The", "Sky", "Is Blue"]
// Split String By Space Using Limits (return array with two elements)
String[] lines = "The Sky Is Blue".split(" ", 2); // ["The", "Sky Is Blue"]
// Split String By Period
String[] number = "012.345.6789".split("\\."); // ["012", "345", "6789"]
// Split String By Space
String[] names = "john bob harry".split(" "); // ["john", "bob", "harry"]
// Split String By Comma
String[] colors = "red,yellow,green,blue".split(","); // ["red", "yellow", "green", "blue"]
// Split String By Comma
String[] colors = "red,yellow,green,blue".split(",");
version: "3"
services:
# Create a service named db.
db:
# Use the Docker Image postgres. This will pull the newest release.
image: "postgres"
# Give the container the name my_postgres. You can changes to something else.
container_name: "my_postgres"
# Setup the username, password, and database name. You can changes these values.
environment:
package main
import "fmt"
func main() {
// Create an slice of 10 integers.
numbers := []int{100, 90, 80, 70, 60, 50, 40, 30, 20, 10}
// Loop over the slice and print the index and elements.