Strings

Strings are chains of characters, sample of a string is :

I am a string

Strings representation

String can be represented with double quotes

"I am a string"

or with single quotes

´I am a string´

Strings concatenation

Strings can be concatenated with  the plus simbol :  +

' I am ' + 'a string'

Strings special characters

  • New line

The new line symbol within a string is represented like this :

\n

Input sample

'I am a String \n with a new line'

Output sample

I am a String
with a new line
  • Tab

The tab symbol within a string is represented like this :

\t

Input sample

'I am a String \t with a tab'

Output sample

I am a String          with a tab
  • Scape

The scape symbol within a string is represented like this :

\

Input sample

'I am a String \"with scaped quotes\"'

Output sample

I am a String "with scaped quotes"

Strings length

The length function can be used with any string in order to get the length of the string, since it is basically an array of characters.

 

Input Sample
"0123456789".length
Output
10 

Strings charAt function

This functions return the character specified at the given position

 

Input Sample
"0123456789".charAt(10)
Output
9