0

String [ ] ex = {"A","B","C"}

Can I define this array As char ?

3rd Nov 2016, 10:23 AM
Dolphin_Alameen
Dolphin_Alameen - avatar
2 Answers
+ 1
string is an array of characters. Yes you can assume it as a character array because it contains one character in each index.
3rd Nov 2016, 10:31 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
0
Yes, of course you can! You can make any array of primitive vars, like int, boolean, long, float, etc. Also, Java allows you to make object arrays, like strings. To make a char array, type: char [ ] ex = new char [13]; // Empty array with length=13 char [ ] ex = {'a', 'b', 'c'}; // Declared array with length=3
3rd Nov 2016, 10:37 AM
Pablo De La Portilla
Pablo De La Portilla - avatar