PLEASE SUBSCRIBE!!!
In the previous video ( • Video ), we introduced the concept of 1-dimensional arrays. Here, we consider a String object as an array of characters. A character is a primitive data type for holding 1-digit characters, which can be strung together to form Strings. This method investigates character codes and implicit casting from char to int.
The char data type holds one individual character. Look at your keyboard to view a collection of characters that can be represented by char: for example, 'R', 'e', '6', '*', '!', ' '. Each of these characters has an ASCII code which can be Googled
Java implicitly casts chars to ints. If you perform some arithmetic operation like System.out.println( 'y' + 2 ), it would return a number that is 2 larger than the ASCII code of the character y. Adding two characters together simply sums their ASCII values. We can explicitly cast to a char by typing (char)(x) for some int x representing an ASCII code
We can convert from an array of characters x to a String y by writing y = String.copyValueOf( x )
We can convert from a String y to an array of characters z by writing z = y.toCharArray( )
1:09 NEW: Intro to char Data Type
2:45 NEW: ASCII Character Encoding
3:45 NEW: Implicit Casting of char to int
7:02 NEW: Explicit Casting of int to char
7:35 NEW: Addition of two chars to Produce the Sum of their ASCII Codes
8:19 NEW: Array of Characters to String Object
11:02 NEW: String Object to Array of Characters
There's a tiny bit about character encoding / ASCII values in Python in the second half of this video: • Python Programming: Lesson 69 - Chara...
Ready for 2-D arrays and escape sequences? Try the next lesson: • Java Programming: Lesson 17 - Escape ...
Thanks for watching and PLEASE SUBSCRIBE!!!