Hi,

Can we declare Char Array in Java instead of String Arrays? So we can manipulate them? or we have to use Strings and then use charAt() method for it?

Thanks

Of course you can declare char arrays, but be aware that each "String" is a char array, so you would need a two dimensional array to hold char arrays equivalent to an array of Strings.

I understan that. What I cann,t understand is showing throgh example. For Example I am going to store char's "A A A A A" in array. for some reasons I want to manipulate it later then how can I do that?

Thanks

That depends on what you mean by "manipulate".

I understan that. What I cann,t understand is showing throgh example. For Example I am going to store char's "A A A A A" in array. for some reasons I want to manipulate it later then how can I do that?

Thanks

where lies the problem? in declaring the array and filling it?

char [] row = new char[5]; // is the same as any other array declaration
for ( int i = 0; i < row.length; i++)
  row[i] = 'A';
// now you have your {'A','A'...} do notice that for chars, you don't use ", but '
// to manipulate the first char of the row (set the value to 'B')
row[0] = 'B';
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.