Programming Languages - Print
Go
import "fmt"
// without new line
fmt.Print()
// with new line
fmt.Println()
// with format
fmt.Printf("Foo = %d", foo)
// print to file
fmt.Fprint(os.Stdout, "Hello ", 23, "\n")
// print to string
s := fmt.Sprintf("%s: %s\n", v1, v2)
format:
%v: (v for value) catchall (use the default conversion). Can print any value, even arrays, slices, structs, and maps.%+v: prints struct field names, e.g.&{a:7 b:-2.35 c:abc def}(%vonly prints values like&{7 -2.35 abc def})%#v: prints the value in full Go syntax, e.g.&main.T{a:7, b:-2.35, c:"abc\tdef"}%q: prints quoted string when applied to a value of typestringor[]byte%#q: use backquote instead.%x: prints hexadecimal strings.% x: similar to%xbut puts spaces between the bytes.%T: prints the type of a value.
Python
# with new line
print("1")
# without new line
print("1", end='')
pprint can pretty-print arbitrary Python data structures
>>> import pprint
>>> pp = pprint.PrettyPrinter(indent=4)
>>> pp.pprint(foo)
Java
// with new line
System.out.println()
// without new line
System.out.print()
// print array
System.out.println(Arrays.toString(arr));
Recommended Reading
SponsoredConcepts
- Overview
- Which Programming Languages To Learn
- Compile Time and Runtime
- Standard Libraries
- Build Tools
- Memory Management
- Zero Cost Abstractions
- Design Patterns
- Constructors
- Compatibility
- Closures
- Functional Programming
- Generics
- String Interning
- Coding Conventions
- Main
- Ranges
- Lambda
- Random
- IO
- Operators
- Built-in
- Constants
- Functions
- Generics
- Print
- Pointers
- Annotations
- Quotes
- Destructuring
- Generators
- Imports
- Iterators
- Testing
- Visibility
- Assignment Semantics
- Slices
- SSA
- Versus
Concurrency
Control Flow
Data Structures

