Monday , December 18 2017
Home / C / Character array c / character array java

Character array c / character array java

Character array in c and character array in java can be implemented in two ways:
1. Character array using pointers: 
Using pointer you can assign a string value to a character array however it will still work as an character array not as a string. The pointer will point to the first index of your assigned string.
char *arr=”hello”;
char *arr;
printf(“%c”, arr);


You can also use it for string array:-

OUTPUT: hello ello llo
2. Character array using Default Datatypes:-
Character array in Java:-
We have a String datatype so no problem at all. You can just implement the array using string datatype in array. 

String a[]={“character”,”array”,”in”,”java”}; for(i=0;i<5;i++) { System.out.println(a[i]); }
Also See:   Program for Matrix Multiplication in JAVA


character array in java

Character array in C:- It is almost similar to that in Java but there we have to use char datatype.

char a[4][10]={“character”,”array”,”in”,”c”}; for(i=0;i<4;i++) { printf(“%s\n “,a[i]); }

OUTPUT: character array in c

Tags: Character array in c, Character array in java.

Check Also

How to find inverse of a matrix in C programming?

In order to find inverse of a matrix in C programming, you need to know ...

One comment

  1. I think other website proprietors should take this site as an example, very clean and great user genial design and style.

Leave a Reply

Your email address will not be published. Required fields are marked *