0
String [ ] ex = {"A","B","C"}
Can I define this array As char ?
2 odpowiedzi
+ 1
string is an array of characters. Yes you can assume it as a character array because it contains one character in each index.
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