Java - Declaring Char Arrays | Arrays in Java

Sharing buttons:

so let's go right now inside the

oncreate method and let's see how we can

declare this kind of phrase so we're

going to go and use the keyword char and

then have this pair of brackets and

afterwards we have to give a name for

our character array and this is

basically just like a string a string

just has more letters or characters and

a character array is more or less the

same thing just a sequence of characters

and we're gonna say for example word

that would be a good example and it just

depends on your application depends on

when you want to use it and so I'm just

gonna initialize right now and add

values all at once so I'm just going to

do this by typing character array and

then we're gonna say for example my

application name and so I'm just gonna

use this square brackets and I'm gonna

say first I'm gonna use this I'm going

to use a pair of single quotes to

enclose this D character and as you can

see you can just do it as you see right

here then you have to use a comma and

specify a couple of others and so we're

gonna just do this right now

and we're gonna say for example we can

just say Android just keep in mind that

you can have two or more characters you

just have to put one character and we're

gonna say Android so I'm just going to

use all these spaces to specify all

these things so we have as you can see

right here Android and this is the word

and basically right now when we have

this application name let's say our

application is called Android and

afterwards you can just initialize

and add values just one by one and so in

order to do this you have to first of

all specify char and then square

brackets and then you have to just give

the name let's say my string just as a

string or just let's a character array

just to be more explicit with this and

we say new character array and so then

you can specify 100 which is 1000

doesn't matter and we're gonna have it

with a default value so it's just gonna

be the new character or just like pretty

much nothing and so we're gonna see

right now how we can do this we're gonna

just add a couple of letters in my

character array and so I'm just gonna

say array of 0 just rate of 0 equals and

then you can add a character you can add

0 go so add numbers just so you know and

then we can go with a cursor at the end

of the line and then just press command

D on a mac or control-d on a PC just

make a couple of more values and you can

also add for example the plus sign or

just X W doesn't matter any kind of

things and so that's how it works