Chars and Strings • tim rodenbröker creative coding

Chars and Strings

Courses / Typemachines / Chars and Strings

Processing

In Processing there are two different variable types that can contain text: Chars and Strings. A char is a single letter and a String is text of any length. In 95% of all cases, using a String makes the most sense. Take a look at these two examples:

char c = 'a';
String txt = "Hi Internet!";

There are two very small syntactical differences between char and String: When using char, the variable type is written in lowercase and single quotation marks are used. For a String, the S must be capitalized and double quotes are always used.

These two rules must be respected, otherwise Processing will refuse to start the sketch.

P5.js

P5.js does not distinguish between the two during initialization.

let c = 'a';
let txt = 'Hi Internet!';

Language Comparison

Processingp5.js
char
Stringstring
Published by Tim on Wednesday July 22, 2020

Last modified on January 17th, 2023 at 11:24

  1. Chars and Strings
  2. Displaying Text
  3. Styling Text
  4. Preloading (p5.js)
  5. Asset-Management
  6. Utilizing a font
  7. Text-Frames
  8. Line-Breaks
  9. Line-Height
  10. String Methods
  11. String Concatenation
  12. Getting the Text-Width
  13. Example: charArt
  14. Example: Newsticker
  15. Example: 3D Typography
  16. Example: Circular Distribution
  17. Addon: Letter Spacing
  18. Wrapping Up